Example #1
0
        /// <summary>
        /// Update the preview according to the changes
        /// </summary>
        private void UpdatePreview()
        {
            if (style != null && enablePreview)
            {
                styleObj pstyle = style.clone();
                Update(pstyle);

                classObj styleclass = new classObj(null);
                styleclass.insertStyle(pstyle, -1);

                using (classObj def_class = new classObj(null)) // for drawing legend images
                {
                    using (imageObj image2 = def_class.createLegendIcon(
                               map, layer, pictureBoxPreview.Width, pictureBoxPreview.Height))
                    {
                        styleclass.drawLegendIcon(map, layer,
                                                  pictureBoxPreview.Width - 10, pictureBoxPreview.Height - 10, image2, 4, 4);
                        byte[] img = image2.getBytes();
                        using (MemoryStream ms = new MemoryStream(img))
                        {
                            pictureBoxPreview.Image = Image.FromStream(ms);
                        }
                    }
                }
            }
            else
            {
                pictureBoxPreview.Image = null;
            }
        }
Example #2
0
        /// <summary>
        /// Update the label object according to the current Editor state.
        /// </summary>
        /// <param name="label">The object to be updated.</param>
        private void Update(labelObj label)
        {
            label.anglemode          = (MS_POSITIONS_ENUM)comboBoxAngleMode.SelectedItem;
            label.autominfeaturesize = checkBoxAutoMinFeatureSize.Checked ? mapscript.MS_TRUE : mapscript.MS_FALSE;
            label.partials           = checkBoxPartials.Checked ? mapscript.MS_TRUE : mapscript.MS_FALSE;
            label.force = checkBoxForce.Checked ? mapscript.MS_TRUE : mapscript.MS_FALSE;

            label.setExpression(this.textBoxExpression.Text);
            label.setText(this.textBoxText.Text);

            colorPickerColor.ApplyTo(label.color);
            colorPickerOutlineColor.ApplyTo(label.outlinecolor);
            colorPickerShadowColor.ApplyTo(label.shadowcolor);

            label.size        = int.Parse(textBoxSize.Text);
            label.minsize     = int.Parse(textBoxMinSize.Text);
            label.maxsize     = int.Parse(textBoxMaxSize.Text);
            label.mindistance = int.Parse(textBoxMinDistance.Text);
            label.offsetx     = int.Parse(textBoxOffsetX.Text);
            label.offsety     = int.Parse(textBoxOffsetY.Text);
            if (textBoxWrap.Text == "")
            {
                label.wrap = '\0';
            }
            else
            {
                label.wrap = Convert.ToChar(textBoxWrap.Text);
            }

            label.shadowsizex = int.Parse(textBoxShadowSizeX.Text);
            label.shadowsizey = int.Parse(textBoxShadowSizeY.Text);

            if (textBoxEncoding.Text == "")
            {
                label.encoding = null;
            }
            else
            {
                label.encoding = textBoxEncoding.Text;
            }
            label.angle = double.Parse(textBoxAngle.Text);

            label.position = (int)comboBoxPosition.SelectedItem;

            label.align = (int)comboBoxAlign.SelectedItem;

            if ((string)(comboBoxFont.SelectedItem) == "(none)")
            {
                label.font = null;
            }
            else
            {
                label.font = (string)(comboBoxFont.SelectedItem);
            }

            label.priority = int.Parse(textBoxPriority.Text);
            if (textBoxMaxScale.Text == "")
            {
                label.maxscaledenom = -1;
            }
            else
            {
                label.maxscaledenom = double.Parse(textBoxMaxScale.Text);
            }

            if (textBoxMinScale.Text == "")
            {
                label.minscaledenom = -1;
            }
            else
            {
                label.minscaledenom = double.Parse(textBoxMinScale.Text);
            }
            label.maxlength      = int.Parse(textBoxMaxLength.Text);
            label.minfeaturesize = int.Parse(textBoxMinFeatureSize.Text);
            label.buffer         = int.Parse(textBoxBuffer.Text);
            label.repeatdistance = int.Parse(textBoxRepeatDistance.Text);

            if (isStyleChanged)
            {
                // reconstruct styles
                while (label.numstyles > 0)
                {
                    label.removeStyle(0);
                }
                // insert styles in reverse order
                for (int i = listViewStyles.Items.Count - 1; i >= 0; --i)
                {
                    ListViewItem item  = listViewStyles.Items[i];
                    styleObj     style = (styleObj)item.Tag;
                    label.insertStyle(style.clone(), -1);
                }
            }
        }
Example #3
0
        private void UpdatePreview()
        {
            if (style != null && enablePreview)
            {
                styleObj pstyle = style.clone();
                Update(pstyle);

                // apply current settings (opacity) to colors
                colorPickerColor.SetColor(pstyle.color);
                colorPickerBackColor.SetColor(pstyle.backgroundcolor);
                colorPickerOutlineColor.SetColor(pstyle.outlinecolor);

                // select the proper map containing symbols
                mapObj stylemap = map;
                if (listView.SelectedItems.Count > 0 && listView.SelectedItems[0].Text != "Default")
                {
                    if (comboBoxCategory.Text != "Inline Symbols")
                    {
                        stylemap = StyleLibrary.Styles;
                    }
                    styleObj classStyle = (styleObj)listView.SelectedItems[0].Tag;
                    pstyle.setSymbolByName(stylemap, classStyle.symbolname);
                }
                else
                {
                    pstyle.symbol     = 0;
                    pstyle.symbolname = null;
                }

                classObj styleclass = new classObj(null);
                styleclass.insertStyle(pstyle, -1);

                using (classObj def_class = new classObj(null)) // for drawing legend images
                {
                    using (imageObj image2 = def_class.createLegendIcon(
                               stylemap, layer, pictureBoxSample.Width, pictureBoxSample.Height))
                    {
                        MS_LAYER_TYPE type = layer.type;
                        try
                        {
                            // modify the layer type in certain cases for drawing correct images
                            if (comboBoxGeomTransform.Text.ToLower().Contains("labelpoly"))
                            {
                                layer.type = MS_LAYER_TYPE.MS_LAYER_POLYGON;
                            }
                            else if (comboBoxGeomTransform.Text.ToLower().Contains("labelpnt") || comboBoxGeomTransform.Text.ToLower().Contains("centroid"))
                            {
                                layer.type = MS_LAYER_TYPE.MS_LAYER_POINT;
                            }

                            styleclass.drawLegendIcon(stylemap, layer,
                                                      pictureBoxSample.Width - 10, pictureBoxSample.Height - 10, image2, 4, 4);
                        }
                        finally
                        {
                            layer.type = type;
                        }

                        byte[] img = image2.getBytes();
                        using (MemoryStream ms = new MemoryStream(img))
                        {
                            pictureBoxSample.Image = Image.FromStream(ms);
                        }
                    }
                }
            }
        }