/// <summary>
 /// Applies color scheme to the visualization categories.
 /// </summary>
 /// <param name="Type">The method of interpolation.</param>
 /// <param name="ColorScheme">The color scheme to take colors from.</param>
 /// <param name="ShapeElement">The element of the shape symbology to apply colors to.</param>
 /// <param name="CategoryStartIndex">The index of the first category to apply colors to.</param>
 /// <param name="CategoryEndIndex">The index of the last category to apply colors to.</param>
 public void ApplyColorScheme3(tkColorSchemeType Type, ColorScheme ColorScheme, tkShapeElements ShapeElement, int CategoryStartIndex, int CategoryEndIndex)
 {
     throw new NotImplementedException();
 }
 /// <summary>
 /// Applies color scheme to the visualization categories.
 /// </summary>
 /// <param name="Type">The method of interpolation.</param>
 /// <param name="ColorScheme">Color scheme to take colors from.</param>
 public void ApplyColorScheme(tkColorSchemeType Type, ColorScheme ColorScheme)
 {
     throw new NotImplementedException();
 }
 /// <summary>
 /// Applies color scheme to the visualization categories.
 /// </summary>
 /// <param name="Type">The method of interpolation.</param>
 /// <param name="ColorScheme">The color scheme to take colors from.</param>
 /// <param name="ShapeElement">The element of the shape symbology to apply colors to.</param>
 public void ApplyColorScheme2(tkColorSchemeType Type, ColorScheme ColorScheme, tkShapeElements ShapeElement)
 {
     throw new NotImplementedException();
 }
        /// <summary>
        /// Generation of labels categories
        /// </summary>
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (cboField.SelectedIndex < 0)
            {
                Globals.MessageBoxInformation("No field for generation was selected");
                this.DialogResult = DialogResult.None;
                return;
            }

            int count = 0;

            if (!Int32.TryParse(cboCategoriesCount.Text, out count))
            {
                Globals.MessageBoxInformation("The entered categories count isn't a number");
                this.DialogResult = DialogResult.None;
                return;
            }

            string fieldName = cboField.SelectedItem.ToString();
            int    index     = -1;

            for (int i = 0; i < m_shapefile.NumFields; i++)
            {
                if (m_shapefile.get_Field(i).Name == fieldName)
                {
                    index = i;
                    break;
                }
            }

            if (index == -1)
            {
                return;
            }

            m_shapefile.Labels.GenerateCategories(index, (MapWinGIS.tkClassificationType)cboClassificationType.SelectedIndex, count);

            if (chkUseVariableSize.Checked)
            {
                int    numCategories = m_shapefile.Labels.NumCategories;
                double step          = (double)(udMaxSize.Value - udMinSize.Value) / ((double)numCategories - 1);
                for (int i = 0; i < numCategories; i++)
                {
                    m_shapefile.Labels.get_Category(i).FontSize = (int)udMinSize.Value + Convert.ToInt32(i * step);
                }
            }

            if (chkGraduatedFrame.Checked)
            {
                ColorBlend            blend  = (ColorBlend)icbFrame.ColorSchemes.List[icbFrame.SelectedIndex];
                MapWinGIS.ColorScheme scheme = ColorSchemes.ColorBlend2ColorScheme(blend);
                tkColorSchemeType     type   = chkRandomColors.Checked ? tkColorSchemeType.ctSchemeRandom : tkColorSchemeType.ctSchemeGraduated;
                m_shapefile.Labels.ApplyColorScheme2(type, scheme, tkLabelElements.leFrameBackground);
            }
            for (int i = 0; i < m_shapefile.Labels.NumCategories; i++)
            {
                m_shapefile.Labels.get_Category(i).FrameVisible = chkGraduatedFrame.Checked;
            }

            m_shapefile.Labels.ApplyCategories();
            SaveSettings();
        }
        /// <summary>
        /// Generates shapefile categories according to specified options
        /// </summary>
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (cboField.SelectedIndex < 0)
            {
                Globals.MessageBoxInformation("No field for generation was selected.");
                this.DialogResult = DialogResult.None;
                return;
            }

            int count;

            if (!Int32.TryParse(cboCategoriesCount.Text, out count))
            {
                Globals.MessageBoxError("Number of categories isn't a valid interger.");
                return;
            }

            MapWinGIS.ShapefileCategories categories = _shapefile.Categories;
            int index = ((ComboItem)cboField.SelectedItem).RealIndex;

            categories.Generate(index, (MapWinGIS.tkClassificationType)cboClassificationType.SelectedIndex, count);

            categories.Caption = "Categories: " + _shapefile.get_Field(index).Name;

            if (chkUseVariableSize.Checked)
            {
                if (_shapefile.ShapefileType == ShpfileType.SHP_POINT || _shapefile.ShapefileType == ShpfileType.SHP_MULTIPOINT)
                {
                    double step = (double)(udMaxSize.Value - udMinSize.Value) / ((double)categories.Count - 1);
                    for (int i = 0; i < categories.Count; i++)
                    {
                        categories.get_Item(i).DrawingOptions.PointSize = (int)udMinSize.Value + Convert.ToInt32(i * step);
                    }
                }
                else if (_shapefile.ShapefileType == ShpfileType.SHP_POLYLINE)
                {
                    double step = (double)(udMaxSize.Value + udMinSize.Value) / (double)categories.Count;
                    for (int i = 0; i < categories.Count; i++)
                    {
                        categories.get_Item(i).DrawingOptions.LineWidth = (int)udMinSize.Value + Convert.ToInt32(i * step);
                    }
                }
            }

            MapWinGIS.ColorScheme scheme = null;
            if (icbColorScheme.SelectedIndex >= 0)
            {
                ColorBlend blend = (ColorBlend)icbColorScheme.ColorSchemes.List[icbColorScheme.SelectedIndex];
                scheme = ColorSchemes.ColorBlend2ColorScheme(blend);
            }

            tkColorSchemeType type = chkRandomColors.Checked ? tkColorSchemeType.ctSchemeRandom : tkColorSchemeType.ctSchemeGraduated;

            _shapefile.Categories.ApplyColorScheme(type, scheme);

            if (chkSetGradient.Checked)
            {
                for (int i = 0; i < categories.Count; i++)
                {
                    ShapeDrawingOptions options = categories.get_Item(i).DrawingOptions;
                    options.SetGradientFill(options.FillColor, 75);
                    options.FillType = tkFillType.ftGradient;
                }
            }

            _shapefile.Categories.ApplyExpressions();

            SaveSettings();
        }
예제 #6
0
 /// <summary>
 /// Generates visualization categories for OGR layer.
 /// </summary>
 /// <param name="Fieldname">%Field name to use as a base for classification.</param>
 /// <param name="ClassificationType">Type of classification.</param>
 /// <param name="numClasses">Number of classes (is not used with unique values classification type).</param>
 /// <param name="colorStart">Starting color for the color scheme.</param>
 /// <param name="colorEnd">End color for the color scheme.</param>
 /// <param name="schemeType">Type of color scheme.</param>
 /// <returns>True on success.</returns>
 /// <remarks> The whole set of features will be used during classification, not only those currently loaded into memory.
 /// Therefore the method has definite advantage over calling OgrLayer.GetBuffer.Categories.Generate
 /// directly for large layers.\n\n
 ///
 /// Categories will be added to underlying shapefile (OgrLayer.GetBuffer). This method
 /// will trigger the population of this shapefile if it's not yet in memory. \n
 ///
 /// The following code opens "buildings" layer, generates categories based on "population"
 /// field and then saves them as a "new_style" to the datasource.\n
 ///
 /// \code
 /// var layer = new OgrLayer();
 /// if (!layer.OpenFromDatabase(CONNECTION_STRING, "buildings"))
 /// {
 ///     Debug.WriteLine("Failed to open the layer: " + layer.GdalLastErrorMsg);
 /// }
 /// else
 /// {
 ///     layer.LabelExpression = "[Name]";
 ///     layer.LabelPosition = tkLabelPositioning.lpCenter;
 ///     layer.GlobalCallback = this;
 ///
 ///     if (!layer.GenerateCategories("population", tkClassificationType.ctEqualIntervals,
 ///         10, tkMapColor.Blue, tkMapColor.Yellow, tkColorSchemeType.ctSchemeGraduated))
 ///     {
 ///         Debug.WriteLine("Failed to generated categories: " + layer.get_ErrorMsg(layer.LastErrorCode));
 ///     }
 ///     else
 ///     {
 ///         var sf = layer.GetBuffer();
 ///         Debug.WriteLine("Number of generated categories: " + sf.Categories.Count);
 ///
 ///         // save it as a new style
 ///         if (!layer.SaveStyle("new_style"))
 ///         {
 ///             Debug.WriteLine("Failed to save style: " + layer.GdalLastErrorMsg);
 ///         }
 ///         else
 ///         {
 ///             Debug.WriteLine("The new style has been saved.");
 ///         }
 ///     }
 ///     layer.Close();
 /// }
 /// \endcode
 /// </remarks>
 public bool GenerateCategories(string Fieldname, tkClassificationType ClassificationType, int numClasses,
                                tkMapColor colorStart, tkMapColor colorEnd, tkColorSchemeType schemeType)
 {
     throw new NotImplementedException();
 }
예제 #7
0
 /// <summary>
 /// Applies specified colors to the exiting breaks of GridColorScheme.
 /// </summary>
 /// <param name="schemeType">Type of the scheme.</param>
 /// <param name="scheme">Colors to apply.</param>
 /// <param name="gradientWithinCategories">If <c>true</c> gradient within each category will be set.</param>
 /// <returns>True on suceess.</returns>
 /// \new494 Added in version 4.9.4
 public bool ApplyColors(tkColorSchemeType schemeType, ColorScheme scheme, bool gradientWithinCategories)
 {
     throw new NotImplementedException();
 }