예제 #1
0
        /// <summary>
        /// Set legend break if draw shape
        /// </summary>
        /// <param name="drawShape"></param>
        public void SetLegendBreak_DrawShape(Boolean drawShape)
        {
            foreach (int rowIdx in _selectedRows)
            {
                switch (_legendScheme.ShapeType)
                {
                case ShapeTypes.Point:
                    PointBreak aPB = (PointBreak)_legendScheme.LegendBreaks[rowIdx];
                    aPB.DrawShape = drawShape;
                    _legendScheme.LegendBreaks[rowIdx] = aPB;
                    break;

                case ShapeTypes.Polyline:
                case ShapeTypes.PolylineZ:
                    PolyLineBreak aPLB = (PolyLineBreak)_legendScheme.LegendBreaks[rowIdx];
                    aPLB.DrawPolyline = drawShape;
                    _legendScheme.LegendBreaks[rowIdx] = aPLB;
                    break;

                case ShapeTypes.Polygon:
                    PolygonBreak aPGB = (PolygonBreak)_legendScheme.LegendBreaks[rowIdx];
                    aPGB.DrawShape = drawShape;
                    _legendScheme.LegendBreaks[rowIdx] = aPGB;
                    break;
                }
            }

            this.Invalidate();
        }
예제 #2
0
        /// <summary>
        /// Set legend break size
        /// </summary>
        /// <param name="aSize">size</param>
        public void SetLegendBreak_Size(Single aSize)
        {
            foreach (int rowIdx in _selectedRows)
            {
                switch (_legendScheme.ShapeType)
                {
                case ShapeTypes.Point:
                    PointBreak aPB = (PointBreak)_legendScheme.LegendBreaks[rowIdx];
                    aPB.Size = aSize;
                    _legendScheme.LegendBreaks[rowIdx] = aPB;
                    break;

                case ShapeTypes.Polyline:
                case ShapeTypes.PolylineZ:
                    PolyLineBreak aPLB = (PolyLineBreak)_legendScheme.LegendBreaks[rowIdx];
                    aPLB.Size = aSize;
                    _legendScheme.LegendBreaks[rowIdx] = aPLB;
                    break;

                case ShapeTypes.Polygon:
                    PolygonBreak aPGB = (PolygonBreak)_legendScheme.LegendBreaks[rowIdx];
                    aPGB.OutlineSize = aSize;
                    _legendScheme.LegendBreaks[rowIdx] = aPGB;
                    break;
                }
            }

            this.Invalidate();
        }
        private void B_NewColor_Click(object sender, EventArgs e)
        {
            int colorNum = _legendScheme.BreakNum;

            if (_legendScheme.ShapeType == ShapeTypes.Polyline)
            {
                colorNum += 1;
            }

            Color[] colors = CreateColors(colorNum);

            int i;

            switch (_legendScheme.ShapeType)
            {
            case ShapeTypes.Point:
                PointBreak aPB = new PointBreak();
                for (i = 0; i < _legendScheme.BreakNum; i++)
                {
                    aPB       = (PointBreak)_legendScheme.LegendBreaks[i];
                    aPB.Color = colors[i];
                    _legendScheme.LegendBreaks[i] = aPB;
                }
                break;

            case ShapeTypes.Polyline:
            case ShapeTypes.PolylineZ:
                PolyLineBreak aPLB = new PolyLineBreak();
                for (i = 0; i < _legendScheme.BreakNum; i++)
                {
                    aPLB       = (PolyLineBreak)_legendScheme.LegendBreaks[i];
                    aPLB.Color = colors[i];
                    _legendScheme.LegendBreaks[i] = aPLB;
                }
                break;

            case ShapeTypes.Polygon:
                PolygonBreak aPGB = new PolygonBreak();
                for (i = 0; i < _legendScheme.BreakNum; i++)
                {
                    aPGB       = (PolygonBreak)_legendScheme.LegendBreaks[i];
                    aPGB.Color = colors[i];
                    _legendScheme.LegendBreaks[i] = aPGB;
                }
                break;
            }

            if (_parent.GetType() == typeof(frmLegendSet))
            {
                ((frmLegendSet)_parent).SetLegendScheme(_legendScheme);
                ((frmLegendSet)_parent).legendView1.Update(_legendScheme);
            }
            else if (_parent.GetType() == typeof(LegendSchemeControl))
            {
                ((LegendSchemeControl)_parent).SetLegendScheme(_legendScheme);
                ((LegendSchemeControl)_parent).legendView1.Update(_legendScheme);
            }
        }
예제 #4
0
        /// <summary>
        /// Set legend break symbol interval
        /// </summary>
        /// <param name="symbolInterval">symbol interval</param>
        public void SetLegendBreak_SymbolInterval(int symbolInterval)
        {
            foreach (int rowIdx in _selectedRows)
            {
                PolyLineBreak aPLB = (PolyLineBreak)_legendScheme.LegendBreaks[rowIdx];
                aPLB.SymbolInterval = symbolInterval;
                _legendScheme.LegendBreaks[rowIdx] = aPLB;
            }

            this.Invalidate();
        }
예제 #5
0
        /// <summary>
        /// Set legend break symbol size
        /// </summary>
        /// <param name="symbolStyle"></param>
        public void SetLegendBreak_SymbolStyle(PointStyle symbolStyle)
        {
            foreach (int rowIdx in _selectedRows)
            {
                PolyLineBreak aPLB = (PolyLineBreak)_legendScheme.LegendBreaks[rowIdx];
                aPLB.SymbolStyle = symbolStyle;
                _legendScheme.LegendBreaks[rowIdx] = aPLB;
            }

            this.Invalidate();
        }
예제 #6
0
        /// <summary>
        /// Set legend break if draw symbol
        /// </summary>
        /// <param name="drawSymbol"></param>
        public void SetLegendBreak_DrawSymbol(bool drawSymbol)
        {
            foreach (int rowIdx in _selectedRows)
            {
                PolyLineBreak aPLB = (PolyLineBreak)_legendScheme.LegendBreaks[rowIdx];
                aPLB.DrawSymbol = drawSymbol;
                _legendScheme.LegendBreaks[rowIdx] = aPLB;
            }

            this.Invalidate();
        }
        private void frmLegendBreaks_Load(object sender, EventArgs e)
        {
            lab_Min.Text = "Min: " + _legendScheme.MinValue.ToString("e1");
            lab_Max.Text = "Max: " + _legendScheme.MaxValue.ToString("e1");
            if (_legendScheme.BreakNum > 2)
            {
                switch (_legendScheme.ShapeType)
                {
                case ShapeTypes.Point:
                    PointBreak aPB = new PointBreak();
                    aPB = (PointBreak)_legendScheme.LegendBreaks[0];
                    m_MinContourValue = double.Parse(aPB.EndValue.ToString());
                    if (_legendScheme.HasNoData)
                    {
                        aPB = (PointBreak)_legendScheme.LegendBreaks[_legendScheme.BreakNum - 2];
                        m_MaxContourValue = double.Parse(aPB.StartValue.ToString());
                        m_Interval        = (m_MaxContourValue - m_MinContourValue) / (_legendScheme.BreakNum - 3);
                    }
                    else
                    {
                        aPB = (PointBreak)_legendScheme.LegendBreaks[_legendScheme.BreakNum - 1];
                        m_MaxContourValue = double.Parse(aPB.StartValue.ToString());
                        m_Interval        = (m_MaxContourValue - m_MinContourValue) / (_legendScheme.BreakNum - 2);
                    }
                    break;

                case ShapeTypes.Polyline:
                case ShapeTypes.PolylineZ:
                    PolyLineBreak aPLB = new PolyLineBreak();
                    aPLB = (PolyLineBreak)_legendScheme.LegendBreaks[0];
                    m_MinContourValue = double.Parse(aPLB.EndValue.ToString());
                    aPLB = (PolyLineBreak)_legendScheme.LegendBreaks[_legendScheme.BreakNum - 1];
                    m_MaxContourValue = double.Parse(aPLB.StartValue.ToString());
                    m_Interval        = (m_MaxContourValue - m_MinContourValue) / (_legendScheme.BreakNum - 1);
                    break;

                case ShapeTypes.Polygon:
                    PolygonBreak aPGB = new PolygonBreak();
                    aPGB = (PolygonBreak)_legendScheme.LegendBreaks[0];
                    m_MinContourValue = double.Parse(aPGB.EndValue.ToString());
                    aPGB = (PolygonBreak)_legendScheme.LegendBreaks[_legendScheme.BreakNum - 1];
                    m_MaxContourValue = double.Parse(aPGB.StartValue.ToString());
                    m_Interval        = (m_MaxContourValue - m_MinContourValue) / (_legendScheme.BreakNum - 2);
                    break;
                }

                TB_SValue.Text   = m_MinContourValue.ToString();
                TB_EValue.Text   = m_MaxContourValue.ToString();
                TB_Interval.Text = m_Interval.ToString();
            }
            RB_RainbowColors.Checked = true;
        }
예제 #8
0
        private void ShowSymbolSetForm(ColorBreak aCB)
        {
            switch (_legendScheme.ShapeType)
            {
            case ShapeTypes.Point:
                PointBreak aPB = (PointBreak)aCB;

                if (!_frmPointSymbolSet.Visible)
                {
                    _frmPointSymbolSet = new frmPointSymbolSet(this);
                    _frmPointSymbolSet.Show(this);
                }
                _frmPointSymbolSet.PointBreak = aPB;
                break;

            case ShapeTypes.Polyline:
            case ShapeTypes.PolylineZ:
                PolyLineBreak aPLB = (PolyLineBreak)aCB;

                if (!_frmPolylineSymbolSet.Visible)
                {
                    _frmPolylineSymbolSet = new frmPolylineSymbolSet(this);
                    _frmPolylineSymbolSet.Show(this);
                }
                _frmPolylineSymbolSet.PolylineBreak = aPLB;
                break;

            case ShapeTypes.Polygon:
                PolygonBreak aPGB = (PolygonBreak)aCB;

                if (!_frmPolygonSymbolSet.Visible)
                {
                    _frmPolygonSymbolSet = new frmPolygonSymbolSet(this);
                    _frmPolygonSymbolSet.Show(this);
                }
                _frmPolygonSymbolSet.PolygonBreak = aPGB;
                break;

            case ShapeTypes.Image:
                if (!_frmColorSymbolSet.Visible)
                {
                    _frmColorSymbolSet = new frmColorSymbolSet(this);
                    _frmColorSymbolSet.Show(this);
                }
                _frmColorSymbolSet.ColorBreak = aCB;
                break;
            }
        }
예제 #9
0
        /// <summary>
        /// Override Clone method
        /// </summary>
        /// <returns>object</returns>
        public override object Clone()
        {
            PolyLineBreak aCB = new PolyLineBreak();

            aCB.Caption        = this.Caption;
            aCB.Color          = this.Color;
            aCB.DrawShape      = this.DrawShape;
            aCB.EndValue       = this.EndValue;
            aCB.IsNoData       = this.IsNoData;
            aCB.StartValue     = this.StartValue;
            aCB.Size           = _size;
            aCB.Style          = _style;
            aCB.DrawPolyline   = _drawPolyline;
            aCB.DrawSymbol     = _drawSymbol;
            aCB.SymbolSize     = _symbolSize;
            aCB.SymbolColor    = _symbolColor;
            aCB.SymbolStyle    = _symbolStyle;
            aCB.SymbolInterval = _symbolInterval;

            return(aCB);
        }
예제 #10
0
        /// <summary>
        /// Create Graduated color legend scheme
        /// </summary>
        /// <param name="CValues"></param>
        /// <param name="colors"></param>
        /// <param name="aST"></param>
        /// <param name="min"></param>
        /// <param name="max"></param>
        /// <param name="hasNodata"></param>
        /// <param name="unDef"></param>
        /// <returns></returns>
        public static LegendScheme CreateGraduatedLegendScheme(double[] CValues, Color[] colors, ShapeTypes aST,
                                                               double min, double max, Boolean hasNodata, double unDef)
        {
            LegendScheme legendScheme = new LegendScheme(aST);

            legendScheme.LegendType   = LegendType.GraduatedColor;
            legendScheme.ShapeType    = aST;
            legendScheme.LegendBreaks = new List <ColorBreak>();
            legendScheme.MinValue     = min;
            legendScheme.MaxValue     = max;
            legendScheme.MissingValue = unDef;
            int i;

            switch (aST)
            {
            case ShapeTypes.Point:
                for (i = 0; i < colors.Length; i++)
                {
                    PointBreak aPB = new PointBreak();
                    aPB.Color        = colors[i];
                    aPB.OutlineColor = Color.Black;
                    aPB.IsNoData     = false;
                    aPB.DrawOutline  = true;
                    aPB.DrawFill     = true;
                    aPB.DrawShape    = true;
                    if (i == 0)
                    {
                        aPB.StartValue = min;
                    }
                    else
                    {
                        aPB.StartValue = CValues[i - 1];
                    }
                    if (i == colors.Length - 1)
                    {
                        aPB.EndValue = max;
                    }
                    else
                    {
                        aPB.EndValue = CValues[i];
                    }
                    aPB.Size  = (Single)i / 2 + 2;
                    aPB.Style = PointStyle.Circle;
                    if (aPB.StartValue == aPB.EndValue)
                    {
                        aPB.Caption = aPB.StartValue.ToString();
                    }
                    else
                    {
                        if (i == 0)
                        {
                            aPB.Caption = "< " + aPB.EndValue.ToString();
                        }
                        else if (i == colors.Length - 1)
                        {
                            aPB.Caption = "> " + aPB.StartValue.ToString();
                        }
                        else
                        {
                            aPB.Caption = aPB.StartValue.ToString() + " - " + aPB.EndValue.ToString();
                        }
                    }

                    legendScheme.LegendBreaks.Add(aPB);
                }
                legendScheme.HasNoData = false;
                if (hasNodata)
                {
                    PointBreak aPB = new PointBreak();
                    aPB.Color        = Color.Gray;
                    aPB.OutlineColor = Color.Black;
                    aPB.StartValue   = unDef;
                    aPB.EndValue     = aPB.StartValue;
                    aPB.Size         = 1;
                    aPB.Style        = PointStyle.Circle;
                    aPB.Caption      = "NoData";
                    aPB.IsNoData     = true;
                    aPB.DrawShape    = true;
                    aPB.DrawOutline  = true;
                    legendScheme.LegendBreaks.Add(aPB);
                    legendScheme.HasNoData = true;
                }
                break;

            case ShapeTypes.Polyline:
            case ShapeTypes.PolylineZ:
                for (i = 0; i < colors.Length; i++)
                {
                    PolyLineBreak aPLB = new PolyLineBreak();
                    aPLB.Color        = colors[i];
                    aPLB.Size         = 1.0F;
                    aPLB.Style        = LineStyles.Solid;
                    aPLB.DrawPolyline = true;
                    if (i == 0)
                    {
                        aPLB.StartValue = min;
                    }
                    else
                    {
                        aPLB.StartValue = CValues[i - 1];
                    }
                    if (i == colors.Length - 1)
                    {
                        aPLB.EndValue = max;
                    }
                    else
                    {
                        aPLB.EndValue = CValues[i];
                    }
                    if (aPLB.StartValue == aPLB.EndValue)
                    {
                        aPLB.Caption = aPLB.StartValue.ToString();
                    }
                    else
                    {
                        if (i == 0)
                        {
                            aPLB.Caption = "< " + aPLB.EndValue.ToString();
                        }
                        else if (i == colors.Length - 1)
                        {
                            aPLB.Caption = "> " + aPLB.StartValue.ToString();
                        }
                        else
                        {
                            aPLB.Caption = aPLB.StartValue.ToString() + " - " + aPLB.EndValue.ToString();
                        }
                    }
                    aPLB.SymbolColor = aPLB.Color;
                    if (Enum.IsDefined(typeof(PointStyle), i))
                    {
                        aPLB.SymbolStyle = (PointStyle)i;
                    }

                    legendScheme.LegendBreaks.Add(aPLB);
                }
                legendScheme.HasNoData = false;
                break;

            case ShapeTypes.Polygon:
                for (i = 0; i < colors.Length; i++)
                {
                    PolygonBreak aPGB = new PolygonBreak();
                    aPGB.Color        = colors[i];
                    aPGB.OutlineColor = Color.Gray;
                    aPGB.OutlineSize  = 1.0F;
                    aPGB.DrawFill     = true;
                    aPGB.DrawOutline  = false;
                    aPGB.DrawShape    = true;
                    if (i == 0)
                    {
                        aPGB.StartValue = min;
                    }
                    else
                    {
                        aPGB.StartValue = CValues[i - 1];
                    }
                    if (i == colors.Length - 1)
                    {
                        aPGB.EndValue = max;
                    }
                    else
                    {
                        aPGB.EndValue = CValues[i];
                    }
                    if (aPGB.StartValue == aPGB.EndValue)
                    {
                        aPGB.Caption = aPGB.StartValue.ToString();
                    }
                    else
                    {
                        if (i == 0)
                        {
                            aPGB.Caption = "< " + aPGB.EndValue.ToString();
                        }
                        else if (i == colors.Length - 1)
                        {
                            aPGB.Caption = "> " + aPGB.StartValue.ToString();
                        }
                        else
                        {
                            aPGB.Caption = aPGB.StartValue.ToString() + " - " + aPGB.EndValue.ToString();
                        }
                    }
                    if (Enum.IsDefined(typeof(HatchStyle), i))
                    {
                        aPGB.Style = (HatchStyle)i;
                    }

                    legendScheme.LegendBreaks.Add(aPGB);
                }
                legendScheme.HasNoData = false;
                break;

            case ShapeTypes.Image:
                for (i = 0; i < colors.Length; i++)
                {
                    ColorBreak aCB = new ColorBreak();
                    aCB.Color = colors[i];
                    if (i == 0)
                    {
                        aCB.StartValue = min;
                    }
                    else
                    {
                        aCB.StartValue = CValues[i - 1];
                    }
                    if (i == colors.Length - 1)
                    {
                        aCB.EndValue = max;
                    }
                    else
                    {
                        aCB.EndValue = CValues[i];
                    }
                    if (aCB.StartValue == aCB.EndValue)
                    {
                        aCB.Caption = aCB.StartValue.ToString();
                    }
                    else
                    {
                        if (i == 0)
                        {
                            aCB.Caption = "< " + aCB.EndValue.ToString();
                        }
                        else if (i == colors.Length - 1)
                        {
                            aCB.Caption = "> " + aCB.StartValue.ToString();
                        }
                        else
                        {
                            aCB.Caption = aCB.StartValue.ToString() + " - " + aCB.EndValue.ToString();
                        }
                    }

                    legendScheme.LegendBreaks.Add(aCB);
                }
                legendScheme.HasNoData = false;
                if (hasNodata)
                {
                    ColorBreak aCB = new ColorBreak();
                    aCB.Color      = Color.Gray;
                    aCB.StartValue = unDef;
                    aCB.EndValue   = aCB.StartValue;
                    aCB.Caption    = "NoData";
                    aCB.IsNoData   = true;
                    legendScheme.LegendBreaks.Add(aCB);
                    legendScheme.HasNoData = true;
                }
                break;
            }
            //legendScheme.breakNum = legendScheme.LegendBreaks.Count;

            return(legendScheme);
        }
예제 #11
0
        /// <summary>
        /// Create unique value legend scheme
        /// </summary>
        /// <param name="CValues"></param>
        /// <param name="captions"></param>
        /// <param name="colors"></param>
        /// <param name="aST"></param>
        /// <param name="min"></param>
        /// <param name="max"></param>
        /// <param name="hasNodata"></param>
        /// <param name="unDef"></param>
        /// <returns></returns>
        public static LegendScheme CreateUniqValueLegendScheme(List <string> CValues, List <string> captions, Color[] colors, ShapeTypes aST,
                                                               double min, double max, Boolean hasNodata, double unDef)
        {
            LegendScheme legendScheme = new LegendScheme(aST);

            legendScheme.LegendType   = LegendType.UniqueValue;
            legendScheme.ShapeType    = aST;
            legendScheme.LegendBreaks = new List <ColorBreak>();
            legendScheme.MinValue     = min;
            legendScheme.MaxValue     = max;
            legendScheme.MissingValue = unDef;
            int        i;
            List <int> idxList = new List <int>();

            switch (aST)
            {
            case ShapeTypes.Point:
            case ShapeTypes.PointZ:
                for (i = 1; i < colors.Length; i++)
                {
                    PointBreak aPB = new PointBreak();
                    aPB.Color      = colors[i];
                    aPB.StartValue = CValues[i - 1];
                    aPB.EndValue   = aPB.StartValue;
                    if (colors.Length <= 13)
                    {
                        aPB.Size = (Single)i / 2 + 2;
                    }
                    else
                    {
                        aPB.Size = 5;
                    }
                    aPB.Style        = PointStyle.Circle;
                    aPB.OutlineColor = Color.Black;
                    aPB.IsNoData     = false;
                    aPB.DrawOutline  = true;
                    aPB.DrawFill     = true;
                    aPB.DrawShape    = true;
                    aPB.Caption      = captions[i - 1];

                    legendScheme.LegendBreaks.Add(aPB);
                }
                legendScheme.HasNoData = false;
                break;

            case ShapeTypes.Polyline:
            case ShapeTypes.PolylineZ:
                idxList = GetEnumList(colors.Length, typeof(PointStyle));
                for (i = 1; i < colors.Length; i++)
                {
                    PolyLineBreak aPLB = new PolyLineBreak();
                    aPLB.Color        = colors[i];
                    aPLB.StartValue   = CValues[i - 1];
                    aPLB.EndValue     = aPLB.StartValue;
                    aPLB.Size         = 1.0F;
                    aPLB.Style        = LineStyles.Solid;
                    aPLB.DrawPolyline = true;
                    aPLB.Caption      = captions[i - 1];
                    aPLB.SymbolColor  = aPLB.Color;
                    aPLB.SymbolStyle  = (PointStyle)idxList[i];

                    legendScheme.LegendBreaks.Add(aPLB);
                }
                legendScheme.HasNoData = false;
                break;

            case ShapeTypes.Polygon:
                idxList = GetEnumList(colors.Length, typeof(HatchStyle));
                for (i = 1; i < colors.Length; i++)
                {
                    PolygonBreak aPGB = new PolygonBreak();
                    aPGB.Color        = colors[i];
                    aPGB.OutlineColor = Color.Gray;
                    aPGB.OutlineSize  = 1.0F;
                    aPGB.DrawFill     = true;
                    aPGB.DrawOutline  = true;
                    aPGB.DrawShape    = true;
                    aPGB.StartValue   = CValues[i - 1];
                    aPGB.EndValue     = aPGB.StartValue;
                    aPGB.Caption      = captions[i - 1];
                    aPGB.Style        = (HatchStyle)idxList[i];

                    legendScheme.LegendBreaks.Add(aPGB);
                }
                legendScheme.HasNoData = false;
                break;
            }
            //legendScheme.breakNum = legendScheme.LegendBreaks.Count;

            return(legendScheme);
        }
예제 #12
0
        /// <summary>
        /// Create single symbol legend scheme
        /// </summary>
        /// <param name="aST">shape type</param>
        /// <param name="aColor">color</param>
        /// <param name="size">size</param>
        /// <returns>legend scheme</returns>
        public static LegendScheme CreateSingleSymbolLegendScheme(ShapeTypes aST, Color aColor,
                                                                  Single size)
        {
            LegendScheme legendScheme = new LegendScheme(aST);

            legendScheme.LegendType   = LegendType.SingleSymbol;
            legendScheme.ShapeType    = aST;
            legendScheme.MinValue     = 0;
            legendScheme.MaxValue     = 0;
            legendScheme.MissingValue = -9999;
            legendScheme.LegendBreaks = new List <ColorBreak>();
            switch (aST)
            {
            case ShapeTypes.Point:
                PointBreak aPB = new PointBreak();
                aPB.Color        = aColor;
                aPB.OutlineColor = Color.Black;
                aPB.Size         = size;
                aPB.IsNoData     = false;
                aPB.DrawFill     = true;
                aPB.DrawOutline  = true;
                aPB.DrawShape    = true;
                aPB.Style        = PointStyle.Circle;
                aPB.StartValue   = 0;
                aPB.EndValue     = 0;
                aPB.Caption      = "";
                legendScheme.LegendBreaks.Add(aPB);
                break;

            case ShapeTypes.Polyline:
            case ShapeTypes.PolylineZ:
                PolyLineBreak aPLB = new PolyLineBreak();
                aPLB.Color        = aColor;
                aPLB.DrawPolyline = true;
                aPLB.Size         = size;
                aPLB.Style        = LineStyles.Solid;
                aPLB.StartValue   = 0;
                aPLB.EndValue     = 0;
                aPLB.Caption      = "";
                aPLB.SymbolColor  = aColor;
                legendScheme.LegendBreaks.Add(aPLB);
                break;

            case ShapeTypes.Polygon:
                PolygonBreak aPGB = new PolygonBreak();
                aPGB.Color        = aColor;
                aPGB.DrawFill     = true;
                aPGB.DrawOutline  = true;
                aPGB.DrawShape    = true;
                aPGB.OutlineColor = Color.Gray;
                aPGB.OutlineSize  = size;
                aPGB.StartValue   = 0;
                aPGB.EndValue     = 0;
                aPGB.Caption      = "";
                legendScheme.LegendBreaks.Add(aPGB);
                break;
            }
            //legendScheme.BreakNum = legendScheme.LegendBreaks.Count;

            return(legendScheme);
        }
        private void DrawCells(Graphics g, int sHeight)
        {
            int hideRows = 0;

            switch (_shapeType)
            {
            case ShapeTypes.Point:
                switch (_markerType)
                {
                case MarkerType.Character:
                    Font smallFont = new Font(Font.FontFamily, _cellSize.Width * .8F, GraphicsUnit.Pixel);
                    for (int i = 0; i < _symbolNumber; i++)
                    {
                        int row = i / _colNumber;
                        if (row > hideRows)
                        {
                            sHeight += _cellSize.Height;
                            hideRows = row;
                        }
                        if (sHeight + _cellSize.Height < this.ClientRectangle.Top)
                        {
                            continue;
                        }

                        int col = i % _colNumber;
                        if (i == _selectedCell)
                        {
                            g.FillRectangle(Brushes.LightSkyBlue, col * _cellSize.Width, sHeight, _cellSize.Width, _cellSize.Height);
                        }

                        string text = ((char)i).ToString();
                        g.DrawString(text, smallFont, Brushes.Black, new System.Drawing.PointF((float)(col * _cellSize.Width), (float)(sHeight)));
                    }
                    break;

                case MarkerType.Simple:
                    PointBreak aPB = new PointBreak();
                    aPB.Color       = Color.Black;
                    aPB.DrawOutline = false;
                    aPB.Size        = _cellSize.Width * 0.8f;
                    for (int i = 0; i < _symbolNumber; i++)
                    {
                        int row = i / _colNumber;
                        if (row > hideRows)
                        {
                            sHeight += _cellSize.Height;
                            hideRows = row;
                        }
                        if (sHeight + _cellSize.Height < this.ClientRectangle.Top)
                        {
                            continue;
                        }

                        int col = i % _colNumber;
                        if (i == _selectedCell)
                        {
                            g.FillRectangle(Brushes.LightSkyBlue, col * _cellSize.Width, sHeight, _cellSize.Width, _cellSize.Height);
                        }

                        PointF sP = new PointF(col * _cellSize.Width + _cellSize.Width / 2,
                                               sHeight + _cellSize.Height / 2);
                        aPB.Style = (PointStyle)i;
                        Draw.DrawPoint(sP, aPB, g);
                    }
                    break;

                case MarkerType.Image:
                    float size = _cellSize.Width * 0.8f;
                    for (int i = 0; i < _symbolNumber; i++)
                    {
                        int row = i / _colNumber;
                        if (row > hideRows)
                        {
                            sHeight += _cellSize.Height;
                            hideRows = row;
                        }
                        if (sHeight + _cellSize.Height < this.ClientRectangle.Top)
                        {
                            continue;
                        }

                        int col = i % _colNumber;
                        if (i == _selectedCell)
                        {
                            g.FillRectangle(Brushes.LightSkyBlue, col * _cellSize.Width, sHeight, _cellSize.Width, _cellSize.Height);
                        }

                        ((Bitmap)_imageList[i]).MakeTransparent(Color.White);
                        g.DrawImage(_imageList[i], col * _cellSize.Width, sHeight, size, size);
                    }
                    break;
                }
                break;

            case ShapeTypes.Polyline:
                PolyLineBreak aPLB = new PolyLineBreak();
                aPLB.Size  = 2;
                aPLB.Color = Color.Black;
                for (int i = 0; i < _symbolNumber; i++)
                {
                    int row = i / _colNumber;
                    if (row > hideRows)
                    {
                        sHeight += _cellSize.Height;
                        hideRows = row;
                    }
                    if (sHeight + _cellSize.Height < this.ClientRectangle.Top)
                    {
                        continue;
                    }

                    int       col  = i % _colNumber;
                    Rectangle rect = new Rectangle(col * _cellSize.Width, sHeight + _cellSize.Height / 4, _cellSize.Width, _cellSize.Height / 2);
                    if (i == _selectedCell)
                    {
                        g.FillRectangle(Brushes.LightSkyBlue, rect);
                    }

                    aPLB.Style = (LineStyles)(Enum.GetValues(typeof(LineStyles)).GetValue(i));
                    Draw.DrawPolyLineSymbol(new PointF(rect.X + rect.Width / 2, rect.Y + rect.Height / 2),
                                            rect.Width * 0.8f, rect.Height * 0.8f, aPLB, g);
                }
                break;

            case ShapeTypes.Polygon:
                PolygonBreak aPGB = new PolygonBreak();
                aPGB.Color        = Color.Red;
                aPGB.OutlineColor = Color.Black;
                for (int i = 0; i < _symbolNumber; i++)
                {
                    int row = i / _colNumber;
                    if (row > hideRows)
                    {
                        sHeight += _cellSize.Height;
                        hideRows = row;
                    }
                    if (sHeight + _cellSize.Height < this.ClientRectangle.Top)
                    {
                        continue;
                    }

                    int       col  = i % _colNumber;
                    Rectangle rect = new Rectangle(col * _cellSize.Width, sHeight, _cellSize.Width, _cellSize.Height);
                    if (i == _selectedCell)
                    {
                        g.FillRectangle(Brushes.LightSkyBlue, rect);
                    }

                    if (i == 0)
                    {
                        aPGB.UsingHatchStyle = false;
                    }
                    else
                    {
                        aPGB.UsingHatchStyle = true;
                        aPGB.Style           = (HatchStyle)(Enum.GetValues(typeof(HatchStyle)).GetValue(i - 1));
                    }
                    Draw.DrawPolygonSymbol(new PointF(rect.X + rect.Width / 2, rect.Y + rect.Height / 2),
                                           rect.Width * 0.8f, rect.Height * 0.8f, aPGB, 0, g);
                }
                break;
            }
        }
예제 #14
0
        private void DrawBreakSymbol(ColorBreak aCB, ShapeTypes shapeType, Rectangle rect, bool selected, Graphics g)
        {
            g.SmoothingMode = SmoothingMode.HighQuality;
            Single aSize;
            PointF aP = new Point(0, 0);
            Single width, height;

            aP.X = rect.Left + rect.Width / 2;
            aP.Y = rect.Top + rect.Height / 2;

            //Draw selected back color
            if (selected)
            {
                g.FillRectangle(Brushes.LightGray, new Rectangle(_symbolWidth, rect.Top, _valueWidth + _labelWidth, rect.Height));
            }

            //Draw symbol
            switch (shapeType)
            {
            case ShapeTypes.Point:
            case ShapeTypes.PointZ:
            case ShapeTypes.WindArraw:
            case ShapeTypes.WindBarb:
            case ShapeTypes.WeatherSymbol:
            case ShapeTypes.StationModel:
                PointBreak aPB = (PointBreak)aCB;
                aSize = aPB.Size;
                if (aPB.DrawShape)
                {
                    //Draw.DrawPoint(aPB.Style, aP, aPB.Color, aPB.OutlineColor,
                    //    aPB.Size, aPB.DrawOutline, aPB.DrawFill, g);
                    if (aPB.MarkerType == MarkerType.Character)
                    {
                        TextRenderingHint aTextRendering = g.TextRenderingHint;
                        g.TextRenderingHint = TextRenderingHint.AntiAlias;
                        Draw.DrawPoint(aP, aPB, g);
                        g.TextRenderingHint = aTextRendering;
                    }
                    else
                    {
                        Draw.DrawPoint(aP, aPB, g);
                    }
                }
                break;

            case ShapeTypes.Polyline:
            case ShapeTypes.PolylineZ:
                PolyLineBreak aPLB = (PolyLineBreak)aCB;
                aSize  = aPLB.Size;
                width  = rect.Width / 3 * 2;
                height = rect.Height / 3 * 2;
                Draw.DrawPolyLineSymbol(aP, width, height, aPLB, g);
                break;

            case ShapeTypes.Polygon:
                PolygonBreak aPGB = (PolygonBreak)aCB;
                width  = rect.Width / 3 * 2;
                height = rect.Height / 5 * 4;
                if (aPGB.DrawShape)
                {
                    //Draw.DrawPolygonSymbol(aP, aPGB.Color, aPGB.OutlineColor, width,
                    //    height, aPGB.DrawFill, aPGB.DrawOutline, g);
                    Draw.DrawPolygonSymbol(aP, width, height, aPGB, 0, g);
                }
                break;

            case ShapeTypes.Image:
                width  = rect.Width / 3 * 2;
                height = rect.Height / 3 * 2;
                Draw.DrawPolygonSymbol(aP, aCB.Color, Color.Black, width,
                                       height, true, true, g);
                break;
            }

            //Draw value and label
            int    sX    = _symbolWidth;
            Font   aFont = new Font("Arial", 8);
            string str   = aCB.Caption;
            SizeF  size  = g.MeasureString(str, aFont);

            aP.X  = sX;
            aP.Y -= size.Height / 2;
            //if (size.Width > _labelWidth)
            //    str = str.Substring(0, 16) + "...";

            if (_legendScheme.LegendType == LegendType.SingleSymbol)
            {
                //Label
                //g.DrawString(str, aFont, Brushes.Black, aP);
                g.DrawString(str, aFont, Brushes.Black, new RectangleF(aP, new SizeF(_valueWidth, size.Height)));
            }
            else
            {
                //Label
                aP.X += _valueWidth;
                g.DrawString(str, aFont, Brushes.Black, aP);

                //Value
                if (aCB.StartValue.ToString() == aCB.EndValue.ToString())
                {
                    str = aCB.StartValue.ToString();
                }
                else
                {
                    str = aCB.StartValue.ToString() + " - " + aCB.EndValue.ToString();
                }

                size = g.MeasureString(str, aFont);
                aP.X = sX;
                //if (size.Width > _labelWidth)
                //    str = str.Substring(0, 16) + "...";

                //g.DrawString(str, aFont, Brushes.Black, aP);
                g.DrawString(str, aFont, Brushes.Black, new RectangleF(aP, new SizeF(_valueWidth, size.Height)));
            }
        }
예제 #15
0
        /// <summary>
        /// Set contour values and colors
        /// </summary>
        /// <param name="aLS"></param>
        /// <param name="cValues"></param>
        /// <param name="colors"></param>
        public static void SetContoursAndColors(LegendScheme aLS, ref double[] cValues, ref Color[] colors)
        {
            int i;

            if (aLS.HasNoData)
            {
                cValues = new double[aLS.BreakNum - 2];
                colors  = new Color[aLS.BreakNum - 1];
            }
            else
            {
                cValues = new double[aLS.BreakNum - 1];
                colors  = new Color[aLS.BreakNum];
            }
            switch (aLS.ShapeType)
            {
            case ShapeTypes.Polygon:
                for (i = 0; i < aLS.BreakNum; i++)
                {
                    PolygonBreak aPGB = (PolygonBreak)aLS.LegendBreaks[i];
                    colors[i] = aPGB.Color;
                    if (i > 0)
                    {
                        cValues[i - 1] = double.Parse(aPGB.StartValue.ToString());
                    }
                }
                break;

            case ShapeTypes.Polyline:
                if (aLS.LegendType == LegendType.UniqueValue)
                {
                    cValues   = new double[aLS.BreakNum];
                    colors    = new Color[aLS.BreakNum + 1];
                    colors[0] = Color.White;
                    for (i = 0; i < aLS.BreakNum; i++)
                    {
                        PolyLineBreak aPLB = (PolyLineBreak)aLS.LegendBreaks[i];
                        colors[i + 1] = aPLB.Color;
                        cValues[i]    = double.Parse(aPLB.StartValue.ToString());
                    }
                }
                else
                {
                    for (i = 0; i < aLS.BreakNum; i++)
                    {
                        PolyLineBreak aPLB = (PolyLineBreak)aLS.LegendBreaks[i];
                        colors[i] = aPLB.Color;
                        if (i > 0)
                        {
                            cValues[i - 1] = double.Parse(aPLB.StartValue.ToString());
                        }
                    }
                }
                break;

            case ShapeTypes.Point:
                for (i = 0; i < aLS.BreakNum; i++)
                {
                    PointBreak aPB = (PointBreak)aLS.LegendBreaks[i];
                    if (!aPB.IsNoData)
                    {
                        colors[i] = aPB.Color;
                        if (i > 0)
                        {
                            cValues[i - 1] = double.Parse(aPB.StartValue.ToString());
                        }
                    }
                }
                break;
            }
        }
예제 #16
0
        private void ImportBreaks(XmlNode parent, bool sameShapeType)
        {
            XmlNode breaks = parent.ChildNodes[0];

            if (sameShapeType)
            {
                switch (ShapeType)
                {
                case ShapeTypes.Point:
                    foreach (XmlNode brk in breaks.ChildNodes)
                    {
                        PointBreak aPB = new PointBreak();
                        try
                        {
                            aPB.Caption      = brk.Attributes["Caption"].InnerText;
                            aPB.StartValue   = brk.Attributes["StartValue"].InnerText;
                            aPB.EndValue     = brk.Attributes["EndValue"].InnerText;
                            aPB.Color        = ColorTranslator.FromHtml(brk.Attributes["Color"].InnerText);
                            aPB.DrawShape    = Convert.ToBoolean(brk.Attributes["DrawShape"].InnerText);
                            aPB.DrawFill     = Convert.ToBoolean(brk.Attributes["DrawFill"].InnerText);
                            aPB.DrawOutline  = Convert.ToBoolean(brk.Attributes["DrawOutline"].InnerText);
                            aPB.IsNoData     = Convert.ToBoolean(brk.Attributes["IsNoData"].InnerText);
                            aPB.OutlineColor = ColorTranslator.FromHtml(brk.Attributes["OutlineColor"].InnerText);
                            aPB.Size         = Convert.ToSingle(brk.Attributes["Size"].InnerText);
                            aPB.Style        = (PointStyle)Enum.Parse(typeof(PointStyle),
                                                                      brk.Attributes["Style"].InnerText, true);
                            aPB.MarkerType = (MarkerType)Enum.Parse(typeof(MarkerType), brk.Attributes["MarkerType"].InnerText, true);
                            aPB.FontName   = brk.Attributes["FontName"].InnerText;
                            aPB.CharIndex  = int.Parse(brk.Attributes["CharIndex"].InnerText);
                            aPB.ImagePath  = brk.Attributes["ImagePath"].InnerText;
                            aPB.Angle      = float.Parse(brk.Attributes["Angle"].InnerText);
                        }
                        catch
                        {
                        }
                        finally
                        {
                            LegendBreaks.Add(aPB);
                        }
                    }
                    break;

                case ShapeTypes.Polyline:
                case ShapeTypes.PolylineZ:
                    foreach (XmlNode brk in breaks.ChildNodes)
                    {
                        PolyLineBreak aPLB = new PolyLineBreak();
                        try
                        {
                            aPLB.Caption      = brk.Attributes["Caption"].InnerText;
                            aPLB.StartValue   = brk.Attributes["StartValue"].InnerText;
                            aPLB.EndValue     = brk.Attributes["EndValue"].InnerText;
                            aPLB.Color        = ColorTranslator.FromHtml(brk.Attributes["Color"].InnerText);
                            aPLB.DrawPolyline = Convert.ToBoolean(brk.Attributes["DrawShape"].InnerText);
                            aPLB.Size         = Convert.ToSingle(brk.Attributes["Size"].InnerText);
                            aPLB.Style        = (LineStyles)Enum.Parse(typeof(LineStyles),
                                                                       brk.Attributes["Style"].InnerText, true);
                            aPLB.DrawSymbol  = bool.Parse(brk.Attributes["DrawSymbol"].InnerText);
                            aPLB.SymbolSize  = Single.Parse(brk.Attributes["SymbolSize"].InnerText);
                            aPLB.SymbolStyle = (PointStyle)Enum.Parse(typeof(PointStyle),
                                                                      brk.Attributes["SymbolStyle"].InnerText, true);
                            aPLB.SymbolColor    = ColorTranslator.FromHtml(brk.Attributes["SymbolColor"].InnerText);
                            aPLB.SymbolInterval = int.Parse(brk.Attributes["SymbolInterval"].InnerText);
                        }
                        catch
                        {
                        }
                        finally
                        {
                            LegendBreaks.Add(aPLB);
                        }
                    }
                    break;

                case ShapeTypes.Polygon:
                    foreach (XmlNode brk in breaks.ChildNodes)
                    {
                        PolygonBreak aPGB = new PolygonBreak();
                        try
                        {
                            aPGB.Caption         = brk.Attributes["Caption"].InnerText;
                            aPGB.StartValue      = brk.Attributes["StartValue"].InnerText;
                            aPGB.EndValue        = brk.Attributes["EndValue"].InnerText;
                            aPGB.Color           = ColorTranslator.FromHtml(brk.Attributes["Color"].InnerText);
                            aPGB.DrawShape       = Convert.ToBoolean(brk.Attributes["DrawShape"].InnerText);
                            aPGB.DrawFill        = Convert.ToBoolean(brk.Attributes["DrawFill"].InnerText);
                            aPGB.DrawOutline     = Convert.ToBoolean(brk.Attributes["DrawOutline"].InnerText);
                            aPGB.OutlineSize     = Convert.ToSingle(brk.Attributes["OutlineSize"].InnerText);
                            aPGB.OutlineColor    = ColorTranslator.FromHtml(brk.Attributes["OutlineColor"].InnerText);
                            aPGB.UsingHatchStyle = bool.Parse(brk.Attributes["UsingHatchStyle"].InnerText);
                            aPGB.Style           = (HatchStyle)Enum.Parse(typeof(HatchStyle), brk.Attributes["Style"].InnerText, true);
                            aPGB.BackColor       = ColorTranslator.FromHtml(brk.Attributes["BackColor"].InnerText);
                        }
                        catch
                        {
                        }
                        finally
                        {
                            LegendBreaks.Add(aPGB);
                        }
                    }
                    break;

                case ShapeTypes.Image:
                    foreach (XmlNode brk in breaks.ChildNodes)
                    {
                        ColorBreak aCB = new ColorBreak();
                        aCB.Caption    = brk.Attributes["Caption"].InnerText;
                        aCB.StartValue = double.Parse(brk.Attributes["StartValue"].InnerText);
                        aCB.EndValue   = double.Parse(brk.Attributes["EndValue"].InnerText);
                        aCB.Color      = ColorTranslator.FromHtml(brk.Attributes["Color"].InnerText);
                        aCB.IsNoData   = bool.Parse(brk.Attributes["IsNoData"].InnerText);
                        LegendBreaks.Add(aCB);
                    }
                    break;
                }
            }
            else
            {
                switch (ShapeType)
                {
                case ShapeTypes.Point:
                    foreach (XmlNode brk in breaks.ChildNodes)
                    {
                        PointBreak aPB = new PointBreak();
                        aPB.Caption    = brk.Attributes["Caption"].InnerText;
                        aPB.StartValue = brk.Attributes["StartValue"].InnerText;
                        aPB.EndValue   = brk.Attributes["EndValue"].InnerText;
                        aPB.Color      = ColorTranslator.FromHtml(brk.Attributes["Color"].InnerText);
                        aPB.DrawShape  = Convert.ToBoolean(brk.Attributes["DrawShape"].InnerText);
                        LegendBreaks.Add(aPB);
                    }
                    break;

                case ShapeTypes.Polyline:
                case ShapeTypes.PolylineZ:
                    foreach (XmlNode brk in breaks.ChildNodes)
                    {
                        if (brk.Attributes["Caption"].InnerText != "NoData")
                        {
                            PolyLineBreak aPLB = new PolyLineBreak();
                            aPLB.Caption      = brk.Attributes["Caption"].InnerText;
                            aPLB.StartValue   = brk.Attributes["StartValue"].InnerText;
                            aPLB.EndValue     = brk.Attributes["EndValue"].InnerText;
                            aPLB.Color        = ColorTranslator.FromHtml(brk.Attributes["Color"].InnerText);
                            aPLB.DrawPolyline = Convert.ToBoolean(brk.Attributes["DrawShape"].InnerText);
                            LegendBreaks.Add(aPLB);
                        }
                    }
                    break;

                case ShapeTypes.Polygon:
                    foreach (XmlNode brk in breaks.ChildNodes)
                    {
                        if (brk.Attributes["Caption"].InnerText != "NoData")
                        {
                            PolygonBreak aPGB = new PolygonBreak();
                            aPGB.Caption    = brk.Attributes["Caption"].InnerText;
                            aPGB.StartValue = Convert.ToDouble(brk.Attributes["StartValue"].InnerText);
                            aPGB.EndValue   = Convert.ToDouble(brk.Attributes["EndValue"].InnerText);
                            aPGB.Color      = ColorTranslator.FromHtml(brk.Attributes["Color"].InnerText);
                            aPGB.DrawShape  = Convert.ToBoolean(brk.Attributes["DrawShape"].InnerText);
                            aPGB.DrawFill   = true;
                            LegendBreaks.Add(aPGB);
                        }
                    }
                    break;

                case ShapeTypes.Image:
                    foreach (XmlNode brk in breaks.ChildNodes)
                    {
                        ColorBreak aCB = new ColorBreak();
                        aCB.Caption    = brk.Attributes["Caption"].InnerText;
                        aCB.StartValue = double.Parse(brk.Attributes["StartValue"].InnerText);
                        aCB.EndValue   = double.Parse(brk.Attributes["EndValue"].InnerText);
                        aCB.Color      = ColorTranslator.FromHtml(brk.Attributes["Color"].InnerText);
                        LegendBreaks.Add(aCB);
                    }
                    break;
                }
                //breakNum = LegendBreaks.Count;
            }
        }
예제 #17
0
        private void TSB_Add_Click(object sender, EventArgs e)
        {
            switch (_legendScheme.ShapeType)
            {
            case ShapeTypes.Polyline:
            case ShapeTypes.PolylineZ:
                PolyLineBreak aPLB = new PolyLineBreak();
                //if (_legendScheme.breakNum > 0)
                //{
                //    aPLB = ((PolyLineBreak)_legendScheme.LegendBreaks[0];
                //}
                aPLB.DrawPolyline = true;
                aPLB.Size         = 0.1F;
                aPLB.Color        = Color.Red;
                aPLB.StartValue   = 0;
                aPLB.EndValue     = 0;
                aPLB.Caption      = "";
                _legendScheme.LegendBreaks.Add(aPLB);
                //_legendScheme.BreakNum = _legendScheme.LegendBreaks.Count;
                break;

            case ShapeTypes.Point:
                PointBreak aPB = new PointBreak();
                //if (_legendScheme.breakNum > 0)
                //{
                //    aPB = (PointBreak)_legendScheme.LegendBreaks[0];
                //}
                aPB.DrawShape  = true;
                aPB.DrawFill   = true;
                aPB.Size       = 5;
                aPB.Color      = Color.Red;
                aPB.StartValue = 0;
                aPB.EndValue   = 0;
                aPB.Caption    = "";
                _legendScheme.LegendBreaks.Add(aPB);
                //_legendScheme.BreakNum = _legendScheme.LegendBreaks.Count;
                break;

            case ShapeTypes.Polygon:
                PolygonBreak aPGB = new PolygonBreak();
                //if (_legendScheme.breakNum > 0)
                //{
                //    aPGB = (PolygonBreak)_legendScheme.LegendBreaks[0];
                //}
                aPGB.DrawShape  = true;
                aPGB.DrawFill   = true;
                aPGB.Color      = Color.Red;
                aPGB.StartValue = 0;
                aPGB.EndValue   = 0;
                aPGB.Caption    = "";
                _legendScheme.LegendBreaks.Add(aPGB);
                //_legendScheme.breakNum = _legendScheme.LegendBreaks.Count;
                break;

            case ShapeTypes.Image:
                ColorBreak aCB = new ColorBreak();
                aCB.Color      = Color.Red;
                aCB.StartValue = 0;
                aCB.EndValue   = 0;
                aCB.Caption    = "";
                _legendScheme.LegendBreaks.Add(aCB);
                //_legendScheme.breakNum = _legendScheme.LegendBreaks.Count;
                break;
            }
            legendView1.Update(_legendScheme);
        }