Пример #1
0
        /// <summary>
        /// Let the editor to update the modified values to the underlying object.
        /// </summary>
        public void UpdateValues()
        {
            if (map == null)
            {
                return;
            }

            if (listView.SelectedItems.Count > 0)
            {
                styleObj style = target;
                mapObj   map2;
                if (target.GetParent().GetType() == typeof(labelObj))
                {
                    map2 = target.GetParent().GetParent().GetParent().GetParent();
                }
                else
                {
                    map2 = target.GetParent().GetParent().GetParent();
                }
                string symbolName = (string)listView.SelectedItems[0].Tag;
                if (symbolName == "(default)")
                {
                    style.symbol     = 0;
                    style.symbolname = null;
                }
                else
                {
                    style.setSymbolByName(map2, symbolName);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Updating the enabled state of the controls
        /// </summary>
        private void UpdateControlState()
        {
            buttonEditStyle.Enabled             = buttonRemoveStyle.Enabled = listViewStyles.SelectedIndices.Count > 0;
            buttonMoveStyleUp.Enabled           = buttonMoveStyleDown.Enabled = listViewStyles.SelectedIndices.Count > 0;
            labelBindingControllerAngle.Enabled = textBoxAngle.Enabled =
                (MS_POSITIONS_ENUM)comboBoxAngleMode.SelectedItem == MS_POSITIONS_ENUM.MS_NONE;

            layerObj layer = null;

            if (target.GetParent().GetParent().GetType() == typeof(layerObj))
            {
                layer = target.GetParent().GetParent();
            }
            if (layer != null)
            {
                checkBoxForce.Enabled = false;
                checkBoxAutoMinFeatureSize.Enabled     = false;
                textBoxMinFeatureSize.Enabled          = false;
                textBoxPriority.Enabled                = false;
                labelBindingControllerPriority.Enabled = false;
                textBoxBuffer.Enabled  = false;
                textBoxMinSize.Enabled = false;
                textBoxMaxSize.Enabled = false;

                if (layer.labelcache == mapscript.MS_ON)
                {
                    checkBoxForce.Enabled = true;
                    checkBoxAutoMinFeatureSize.Enabled     = true;
                    textBoxMinFeatureSize.Enabled          = true;
                    textBoxPriority.Enabled                = true;
                    labelBindingControllerPriority.Enabled = true;
                    textBoxBuffer.Enabled = true;
                }
                if (layer.symbolscaledenom > 0)
                {
                    textBoxMinSize.Enabled = true;
                    textBoxMaxSize.Enabled = true;
                }

                buttonMoveStyleUp.Enabled   = false;
                buttonMoveStyleDown.Enabled = false;
                buttonEditStyle.Enabled     = false;
                if (listViewStyles.SelectedIndices.Count > 0)
                {
                    buttonEditStyle.Enabled = true;
                    if (listViewStyles.SelectedIndices[0] > 0)
                    {
                        buttonMoveStyleUp.Enabled = true;
                    }
                    if (listViewStyles.SelectedIndices[0] < listViewStyles.Items.Count - 1)
                    {
                        buttonMoveStyleDown.Enabled = true;
                    }
                }
            }
        }
        /// <summary>
        /// Create the theme according to the individual values of the layer contents
        /// </summary>
        private MapObjectHolder CreateLayerTheme()
        {
            if (layer == null)
            {
                return(null);
            }

            mapObj map = target.GetParent();

            // create a new map object
            mapObj newMap = new mapObj(null);

            newMap.units = MS_UNITS.MS_PIXELS;
            map.selectOutputFormat(map.imagetype);
            // copy symbolset
            for (int s = 1; s < map.symbolset.numsymbols; s++)
            {
                symbolObj origsym = map.symbolset.getSymbol(s);
                newMap.symbolset.appendSymbol(MapUtils.CloneSymbol(origsym));
            }
            // copy the fontset
            string key = null;

            while ((key = map.fontset.fonts.nextKey(key)) != null)
            {
                newMap.fontset.fonts.set(key, map.fontset.fonts.get(key, ""));
            }

            newLayer                = new layerObj(newMap);
            newLayer.type           = layer.type;
            newLayer.status         = mapscript.MS_ON;
            newLayer.connectiontype = MS_CONNECTION_TYPE.MS_INLINE;
            // add the classObj and styles
            classObj classobj;

            if (checkBoxKeepStyles.Checked)
            {
                classobj = layer.getClass(0).clone();
                classobj.setExpression(""); // remove expression to have the class shown
                // bindings are not supported with sample maps
                for (int s = 0; s < classobj.numstyles; s++)
                {
                    StyleBindingController.RemoveAllBindings(classobj.getStyle(s));
                }
                for (int l = 0; l < classobj.numlabels; l++)
                {
                    LabelBindingController.RemoveAllBindings(classobj.getLabel(l));
                }
                newLayer.insertClass(classobj, -1);
            }
            else
            {
                classobj      = new classObj(newLayer);
                classobj.name = MapUtils.GetClassName(newLayer);
                styleObj style = new styleObj(classobj);
                style.size = 8; // set default size (#4339)

                if (layer.type == MS_LAYER_TYPE.MS_LAYER_POINT)
                {
                    // initialize with the default marker if specified in the symbol file for point symbols
                    symbolObj symbol;
                    for (int s = 0; s < map.symbolset.numsymbols; s++)
                    {
                        symbol = map.symbolset.getSymbol(s);

                        if (symbol.name == "default-marker")
                        {
                            style.symbol     = s;
                            style.symbolname = "default-marker";
                            break;
                        }
                    }
                }
                MapUtils.SetDefaultColor(layer.type, style);
            }

            SortedDictionary <string, string> items = new SortedDictionary <string, string>();
            int i = 0;

            shapeObj shape;

            layer.open();

            layer.whichShapes(layer.getExtent());

            if (checkBoxClassItem.Checked)
            {
                layer.classitem = comboBoxColumns.SelectedItem.ToString();
            }

            while ((shape = layer.nextShape()) != null)
            {
                string value = shape.getValue(comboBoxColumns.SelectedIndex);
                if (checkBoxZero.Checked && (value == "" || value == ""))
                {
                    continue;
                }

                if (!items.ContainsValue(value))
                {
                    if (i == 100)
                    {
                        if (MessageBox.Show("The number of the individual values is greater than 100 would you like to continue?", "MapManager",
                                            MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.Cancel)
                        {
                            break;
                        }
                    }

                    items.Add(value, value);

                    ++i;
                }
            }

            if (layer.getResults() == null)
            {
                layer.close(); // close only is no query results
            }
            i = 0;
            foreach (string value in items.Keys)
            {
                double percent = ((double)(i + 1)) / items.Count * 100;

                // creating the corresponding class object
                if (i > 0)
                {
                    classobj = classobj.clone();
                    // bindings are not supported with sample maps
                    for (int s = 0; s < classobj.numstyles; s++)
                    {
                        StyleBindingController.RemoveAllBindings(classobj.getStyle(s));
                    }
                    for (int l = 0; l < classobj.numlabels; l++)
                    {
                        LabelBindingController.RemoveAllBindings(classobj.getLabel(l));
                    }
                    newLayer.insertClass(classobj, -1);
                }

                classobj.name = value;
                if (checkBoxClassItem.Checked)
                {
                    classobj.setExpression(value);
                }
                else
                {
                    classobj.setExpression("('[" + comboBoxColumns.SelectedItem + "]' = '" + value + "')");
                }

                for (int j = 0; j < classobj.numstyles; j++)
                {
                    styleObj style = classobj.getStyle(j);
                    style.color           = colorRampPickerColor.GetMapColorAtValue(percent);
                    style.outlinecolor    = colorRampPickerOutlineColor.GetMapColorAtValue(percent);
                    style.backgroundcolor = colorRampPickerBackgroundColor.GetMapColorAtValue(percent);

                    if (checkBoxFirstOnly.Checked)
                    {
                        break;
                    }
                }
                ++i;
            }

            return(new MapObjectHolder(newLayer, new MapObjectHolder(newMap, null)));
        }
Пример #4
0
        /// <summary>
        /// Adding a new labelObj to the corresponding classObj.
        /// </summary>
        /// <param name="nodes">The TreeNodeCollection of the parent object</param>
        /// <param name="labelHolder">Wrapper class containing the labelObj and the parent object</param>
        /// <param name="imageList">The image list where the label image should be stored.</param>
        /// <param name="index">The current index of the label object.</param>
        private void AddLabelNode(TreeNodeCollection nodes, MapObjectHolder labelHolder, ImageList imageList, int index)
        {
            layerObj layer = labelHolder.GetParent().GetParent();
            classObj layerclass = labelHolder.GetParent();
            labelObj classLabel = labelHolder;

            classObj labelclass = new classObj(null);
            labelclass.name = MapUtils.GetClassName(layer);
            labelclass.addLabel(classLabel);
            // creating the treeicons
            using (classObj def_class = new classObj(null)) // for drawing legend images
            {
                using (imageObj image2 = def_class.createLegendIcon(
                                map, layer, legendIconSize.Width, legendIconSize.Height))
                {
                    MS_LAYER_TYPE layertype = layer.type;
                    layer.type = MS_LAYER_TYPE.MS_LAYER_ANNOTATION;
                    labelclass.drawLegendIcon(map, layer,
                        legendDrawingSize.Width, legendDrawingSize.Height, image2,
                        LegendIconPadding.Left, LegendIconPadding.Top);
                    layer.type = layertype;
                    byte[] img = image2.getBytes();
                    using (MemoryStream ms = new MemoryStream(img))
                    {
                        imageList.Images.Add(Image.FromStream(ms));
                    }

                    TreeNode labelNode = new TreeNode("Label (" + index + ")",
                        imageList.Images.Count - 1, imageList.Images.Count - 1);
                    labelNode.Tag = labelHolder;
                    labelNode.Checked = true;
                    nodes.Add(labelNode);
                }
            }
        }
Пример #5
0
        /// <summary>
        /// Creating a sample (preview) based on a classObj, styleObj or labelObj.
        /// </summary>
        /// <param name="original">The wrapper holding the original object.</param>
        private void CreateSampleMap(MapObjectHolder original)
        {
            MapObjectHolder originalMap = null;
            MapObjectHolder originalLayer = null;
            MapObjectHolder originalClass = null;
            // create a sample map to render a preview of the given object
            if (original.GetType() == typeof(classObj))
            {
                // tracking down the whole object tree
                originalLayer = original.GetParent();
                if (originalLayer != null)
                    originalMap = originalLayer.GetParent();
                // creating a new compatible map object
                if (originalMap != null)
                {
                    layerObj layer = InitializeDefaultLayer(originalMap, originalLayer);
                    layer.insertClass(((classObj)original).clone(), -1);
                    // bindings are not supported with sample maps
                    classObj classobj = layer.getClass(0);
                    for (int i = 0; i < classobj.numstyles; i++)
                        StyleBindingController.RemoveAllBindings(classobj.getStyle(i));
                    for (int i = 0; i < classobj.numlabels; i++)
                        LabelBindingController.RemoveAllBindings(classobj.getLabel(i));
                    classobj.setText("Sample text");
                    classobj.setExpression(""); // remove expression to have the class shown

                    this.target = new MapObjectHolder(classobj, original.GetParent());
                }
            }
            else if (original.GetType() == typeof(styleObj))
            {
                // tracking down the whole object tree
                if (original.GetParent().GetType() == typeof(labelObj))
                    originalClass = original.GetParent().GetParent();
                else
                    originalClass = original.GetParent();
                if (originalClass != null)
                    originalLayer = originalClass.GetParent();
                if (originalLayer != null)
                    originalMap = originalLayer.GetParent();
                // creating a new compatible map object
                if (originalMap != null)
                {
                    layerObj layer = InitializeDefaultLayer(originalMap, originalLayer);
                    classObj classobj = new classObj(layer);
                    classobj.name = MapUtils.GetClassName(layer);
                    styleObj style;
                    if (original.GetParent().GetType() == typeof(labelObj))
                    {

                        classobj.addLabel(new labelObj());
                        labelObj label = classobj.getLabel(classobj.numlabels - 1);
                        MapUtils.SetDefaultLabel(label, layer.map);
                        label.insertStyle(((styleObj)original).clone(), -1);
                        style = label.getStyle(0);
                    }
                    else
                    {
                        classobj.insertStyle(((styleObj)original).clone(), -1);
                        style = classobj.getStyle(0);
                    }

                    // bindings are not supported with sample maps
                    StyleBindingController.RemoveAllBindings(style);
                    classobj.setText("Sample text");
                    this.target = new MapObjectHolder(style, original.GetParent());
                }
            }
            else if (original.GetType() == typeof(labelObj))
            {
                // tracking down the whole object tree
                originalClass = original.GetParent();
                if (originalClass != null)
                {
                    if (originalClass.GetType() == typeof(classObj))
                    {
                        originalLayer = originalClass.GetParent();
                        if (originalLayer != null)
                            originalMap = originalLayer.GetParent();
                    }
                    else if (originalClass.GetType() == typeof(scalebarObj))
                    {
                        originalMap = originalClass.GetParent();
                    }
                }

                // creating a new compatible map object
                if (originalMap != null)
                {
                    layerObj layer = InitializeDefaultLayer(originalMap, originalLayer);
                    classObj classobj = new classObj(layer);
                    classobj.name = MapUtils.GetClassName(layer);
                    labelObj label = new labelObj();

                    if (originalClass.GetType() == typeof(classObj))
                    {
                        // copy settings
                        label.updateFromString(((labelObj)original).convertToString());
                    }
                    classobj.addLabel(label);

                    this.target = new MapObjectHolder(layer.getClass(0).getLabel(0), original.GetParent());
                }
            }
            else
                throw new Exception("Invalid target type: " + original.GetType());
        }
Пример #6
0
        /// <summary>
        /// Adding a new classObj to the corresponding layerObj.
        /// </summary>
        /// <param name="nodes">The TreeNodeCollection of the parent object</param>
        /// <param name="classHolder">Wrapper class containing the classObj and the parent object</param>
        /// /// <param name="showRoot">A flag indicating whether the root object should be displayed or not.</param>
        private void AddClassNode(TreeNodeCollection nodes, MapObjectHolder classHolder, ImageList imageList)
        {
            layerObj layer = classHolder.GetParent();
            classObj layerclass = classHolder;

            // creating the treeicons
            using (classObj def_class = new classObj(null)) // for drawing legend images
            {
                using (imageObj image = def_class.createLegendIcon(
                                map, layer, legendIconSize.Width, legendIconSize.Height))
                {
                    // drawing the class icons
                    layerclass.drawLegendIcon(map, layer,
                        legendDrawingSize.Width, legendDrawingSize.Height, image,
                        LegendIconPadding.Left, LegendIconPadding.Top);
                    byte[] img = image.getBytes();
                    using (MemoryStream ms = new MemoryStream(img))
                    {
                        imageList.Images.Add(Image.FromStream(ms));
                    }

                    if (!showClasses || string.Compare(layer.styleitem, "AUTO", true) == 0)
                        return;

                    TreeNode classNode = null;
                    if (layer.numclasses > 1 ||
                        (layer.numclasses == 1 && target.GetType() == typeof(layerObj) && showRootObject == false)) // classes should always be shown if the layer is not shown (#7118)
                    {
                        classNode = new TreeNode(layerclass.name, imageList.Images.Count - 1,
                                imageList.Images.Count - 1);
                        classNode.Tag = classHolder;
                        classNode.Checked = (layerclass.status != mapscript.MS_OFF);
                        nodes.Add(classNode);
                        nodes = classNode.Nodes;
                    }

                    // drawing the style icons
                    if (showStyles)
                    {
                        for (int k = 0; k < layerclass.numstyles; k++)
                        {
                            styleObj classStyle = layerclass.getStyle(k);

                            if (layerclass.numstyles > 1)
                            {
                                AddStyleNode(nodes, new MapObjectHolder(classStyle, classHolder), imageList);
                            }
                        }
                    }

                    // drawing the labels icons
                    if (showLabels)
                    {
                        for (int l = 0; l < layerclass.numlabels; l++)
                        {
                            labelObj classLabel = layerclass.getLabel(l);

                            if (layerclass.numlabels > 1)
                            {
                                AddLabelNode(nodes, new MapObjectHolder(classLabel, classHolder), imageList, l);
                            }
                        }
                    }
                }
            }
        }
Пример #7
0
        /// <summary>
        /// Adding a new styleObj to the corresponding classObj.
        /// </summary>
        /// <param name="nodes">The TreeNodeCollection of the parent object</param>
        /// <param name="styleHolder">Wrapper class containing the styleObj and the parent object</param>
        /// /// <param name="showRoot">A flag indicating whether the root object should be displayed or not.</param>
        private void AddStyleNode(TreeNodeCollection nodes, MapObjectHolder styleHolder, ImageList imageList)
        {
            layerObj layer = styleHolder.GetParent().GetParent();
            classObj layerclass = styleHolder.GetParent();
            styleObj classStyle = styleHolder;

            classObj styleclass = new classObj(null);
            styleclass.name = MapUtils.GetClassName(layer);
            styleclass.insertStyle(classStyle, -1);
            // creating the treeicons
            using (classObj def_class = new classObj(null)) // for drawing legend images
            {
                using (imageObj image2 = def_class.createLegendIcon(
                                 map, layer, legendIconSize.Width, legendIconSize.Height))
                {
                    styleclass.drawLegendIcon(map, layer,
                        legendDrawingSize.Width, legendDrawingSize.Height, image2,
                        LegendIconPadding.Left, LegendIconPadding.Top);
                    byte[] img = image2.getBytes();
                    using (MemoryStream ms = new MemoryStream(img))
                    {
                        imageList.Images.Add(Image.FromStream(ms));
                    }

                    TreeNode styleNode = new TreeNode("Style (" + nodes.Count + ")",
                        imageList.Images.Count - 1, imageList.Images.Count - 1);
                    styleNode.Tag = styleHolder;
                    styleNode.Checked = true;
                    nodes.Add(styleNode);
                }
            }
        }
Пример #8
0
        public override void InitializeBinding(MapObjectHolder target)
        {
            this.target = target;

            if (target.GetParent().GetParent().GetType() != typeof(layerObj))
            {
                this.Enabled = false;
                return;
            }

            layerObj layer = target.GetParent().GetParent();
            styleObj style = target;
            if (itemList == null)
            {
                itemList = new ComboBox();
                itemList.Width = targetControl.Width;
                itemList.Height = targetControl.Height;
                itemList.Location = targetControl.Location;
                itemList.DropDownStyle = ComboBoxStyle.DropDownList;
                itemList.SelectedIndexChanged += new EventHandler(itemList_SelectedIndexChanged);
                targetControl.Parent.Controls.Add(itemList);
                itemList.BringToFront();
                Bitmap bmp = Resources.DataConnection;
                bmp.MakeTransparent(Color.Magenta);
                pbox = new PictureBox();
                pbox.Image = bmp;
                pbox.SizeMode = PictureBoxSizeMode.AutoSize;
                pbox.Location = new System.Drawing.Point(targetControl.Location.X + targetControl.Width + 2,
                    targetControl.Location.Y + (targetControl.Height - pbox.Image.Height) / 2);
                targetControl.Parent.Controls.Add(pbox);
                pbox.BringToFront();
            }

            BindingState = false;

            itemList.Items.Clear();
            layer.open();
            for (int i = 0; i < layer.numitems; i++)
                itemList.Items.Add(layer.getItem(i));
            if (layer.getResults() == null)
                layer.close(); // close only is no query results

            if (layer.connectiontype == MS_CONNECTION_TYPE.MS_OGR)
            {
                itemList.Items.Add("OGR:LabelFont");
                itemList.Items.Add("OGR:LabelSize");
                itemList.Items.Add("OGR:LabelText");
                itemList.Items.Add("OGR:LabelAngle");
                itemList.Items.Add("OGR:LabelFColor");
                itemList.Items.Add("OGR:LabelBColor");
                itemList.Items.Add("OGR:LabelPlacement");
                itemList.Items.Add("OGR:LabelAnchor");
                itemList.Items.Add("OGR:LabelDx");
                itemList.Items.Add("OGR:LabelDy");
                itemList.Items.Add("OGR:LabelPerp");
                itemList.Items.Add("OGR:LabelBold");
                itemList.Items.Add("OGR:LabelItalic");
                itemList.Items.Add("OGR:LabelUnderline");
                itemList.Items.Add("OGR:LabelPriority");
                itemList.Items.Add("OGR:LabelStrikeout");
                itemList.Items.Add("OGR:LabelStretch");
                itemList.Items.Add("OGR:LabelAdjHor");
                itemList.Items.Add("OGR:LabelAdjVert");
                itemList.Items.Add("OGR:LabelHColor");
                itemList.Items.Add("OGR:LabelOColor");
            }

            string binding = style.getBinding((int)styleBinding);
            if (binding != null)
            {
                itemList.SelectedItem = binding;
                BindingState = true;
            }
            else
            {
                if (itemList.Items.Count > 0)
                    itemList.SelectedIndex = 0;
            }
        }
Пример #9
0
        /// <summary>
        /// Create the theme according to the individual values of the layer contents
        /// </summary>
        private MapObjectHolder CreateLayerTheme()
        {
            if (layer == null)
            {
                return(null);
            }

            int index;

            for (index = 0; index < fieldName.Length; index++)
            {
                if (fieldName[index] == comboBoxColumns.Text)
                {
                    break;
                }
            }
            if (index == fieldName.Length)
            {
                return(null);
            }

            NumberFormatInfo ni = new NumberFormatInfo();

            ni.NumberDecimalSeparator = ".";
            mapObj map = target.GetParent();

            // create a new map object
            mapObj newMap = new mapObj(null);

            newMap.units = MS_UNITS.MS_PIXELS;
            map.selectOutputFormat(map.imagetype);
            // copy symbolset
            for (int s = 1; s < map.symbolset.numsymbols; s++)
            {
                symbolObj origsym = map.symbolset.getSymbol(s);
                newMap.symbolset.appendSymbol(MapUtils.CloneSymbol(origsym));
            }
            // copy the fontset
            string key = null;

            while ((key = map.fontset.fonts.nextKey(key)) != null)
            {
                newMap.fontset.fonts.set(key, map.fontset.fonts.get(key, ""));
            }

            newLayer                = new layerObj(newMap);
            newLayer.type           = layer.type;
            newLayer.status         = mapscript.MS_ON;
            newLayer.connectiontype = MS_CONNECTION_TYPE.MS_INLINE;
            // add the classObj and styles
            classObj classobj;

            if (checkBoxKeepStyles.Checked)
            {
                classobj = layer.getClass(0).clone();
                classobj.setExpression(""); // remove expression to have the class shown
                // bindings are not supported with sample maps
                for (int s = 0; s < classobj.numstyles; s++)
                {
                    StyleBindingController.RemoveAllBindings(classobj.getStyle(s));
                }
                for (int l = 0; l < classobj.numlabels; l++)
                {
                    LabelBindingController.RemoveAllBindings(classobj.getLabel(l));
                }
                newLayer.insertClass(classobj, -1);
            }
            else
            {
                classobj      = new classObj(newLayer);
                classobj.name = MapUtils.GetClassName(newLayer);
                styleObj style = new styleObj(classobj);
                style.size = 8; // set default size (#4339)

                if (layer.type == MS_LAYER_TYPE.MS_LAYER_POINT)
                {
                    // initialize with the default marker if specified in the symbol file for point symbols
                    symbolObj symbol;
                    for (int s = 0; s < map.symbolset.numsymbols; s++)
                    {
                        symbol = map.symbolset.getSymbol(s);

                        if (symbol.name == "default-marker")
                        {
                            style.symbol     = s;
                            style.symbolname = "default-marker";
                            break;
                        }
                    }
                }
                MapUtils.SetDefaultColor(layer.type, style);
            }

            // calculate breaks
            int classes = (int)numericUpDownClasses.Value;

            double[] breaks = null;
            if (comboBoxMode.SelectedIndex == 0)
            {
                breaks = CalculateEqualInterval(classes, index);
            }

            if (breaks == null)
            {
                return(null);
            }

            for (int i = 0; i < classes; i++)
            {
                double percent = ((double)(i + 1)) / classes * 100;
                // creating the corresponding class object
                if (i > 0)
                {
                    classobj = classobj.clone();
                    // bindings are not supported with sample maps
                    for (int s = 0; s < classobj.numstyles; s++)
                    {
                        StyleBindingController.RemoveAllBindings(classobj.getStyle(s));
                    }
                    for (int l = 0; l < classobj.numlabels; l++)
                    {
                        LabelBindingController.RemoveAllBindings(classobj.getLabel(l));
                    }
                    newLayer.insertClass(classobj, -1);
                }

                classobj.name = breaks[i].ToString(ni) + " - " + breaks[i + 1].ToString(ni);
                classobj.setExpression("(([" + comboBoxColumns.SelectedItem + "] >= "
                                       + breaks[i].ToString(ni) + ") && ([" + comboBoxColumns.SelectedItem + "] <= "
                                       + breaks[i + 1].ToString(ni) + "))");
                for (int j = 0; j < classobj.numstyles; j++)
                {
                    styleObj style = classobj.getStyle(j);
                    style.color           = colorRampPickerColor.GetMapColorAtValue(percent);
                    style.outlinecolor    = colorRampPickerOutlineColor.GetMapColorAtValue(percent);
                    style.backgroundcolor = colorRampPickerBackgroundColor.GetMapColorAtValue(percent);

                    if (checkBoxFirstOnly.Checked)
                    {
                        break;
                    }
                }
            }

            return(new MapObjectHolder(newLayer, new MapObjectHolder(newMap, null)));
        }
Пример #10
0
        public override void InitializeBinding(MapObjectHolder target)
        {
            this.target = target;

            if (target.GetParent().GetParent().GetType() != typeof(layerObj))
            {
                this.Enabled = false;
                return;
            }

            layerObj layer = target.GetParent().GetParent();
            styleObj style = target;

            if (itemList == null)
            {
                itemList                       = new ComboBox();
                itemList.Width                 = targetControl.Width;
                itemList.Height                = targetControl.Height;
                itemList.Location              = targetControl.Location;
                itemList.DropDownStyle         = ComboBoxStyle.DropDownList;
                itemList.SelectedIndexChanged += new EventHandler(itemList_SelectedIndexChanged);
                targetControl.Parent.Controls.Add(itemList);
                itemList.BringToFront();
                Bitmap bmp = Resources.DataConnection;
                bmp.MakeTransparent(Color.Magenta);
                pbox          = new PictureBox();
                pbox.Image    = bmp;
                pbox.SizeMode = PictureBoxSizeMode.AutoSize;
                pbox.Location = new System.Drawing.Point(targetControl.Location.X + targetControl.Width + 2,
                                                         targetControl.Location.Y + (targetControl.Height - pbox.Image.Height) / 2);
                targetControl.Parent.Controls.Add(pbox);
                pbox.BringToFront();
            }

            BindingState = false;

            itemList.Items.Clear();
            layer.open();
            for (int i = 0; i < layer.numitems; i++)
            {
                itemList.Items.Add(layer.getItem(i));
            }
            if (layer.getResults() == null)
            {
                layer.close(); // close only is no query results
            }
            if (layer.connectiontype == MS_CONNECTION_TYPE.MS_OGR)
            {
                itemList.Items.Add("OGR:LabelFont");
                itemList.Items.Add("OGR:LabelSize");
                itemList.Items.Add("OGR:LabelText");
                itemList.Items.Add("OGR:LabelAngle");
                itemList.Items.Add("OGR:LabelFColor");
                itemList.Items.Add("OGR:LabelBColor");
                itemList.Items.Add("OGR:LabelPlacement");
                itemList.Items.Add("OGR:LabelAnchor");
                itemList.Items.Add("OGR:LabelDx");
                itemList.Items.Add("OGR:LabelDy");
                itemList.Items.Add("OGR:LabelPerp");
                itemList.Items.Add("OGR:LabelBold");
                itemList.Items.Add("OGR:LabelItalic");
                itemList.Items.Add("OGR:LabelUnderline");
                itemList.Items.Add("OGR:LabelPriority");
                itemList.Items.Add("OGR:LabelStrikeout");
                itemList.Items.Add("OGR:LabelStretch");
                itemList.Items.Add("OGR:LabelAdjHor");
                itemList.Items.Add("OGR:LabelAdjVert");
                itemList.Items.Add("OGR:LabelHColor");
                itemList.Items.Add("OGR:LabelOColor");
            }

            string binding = style.getBinding((int)styleBinding);

            if (binding != null)
            {
                itemList.SelectedItem = binding;
                BindingState          = true;
            }
            else
            {
                if (itemList.Items.Count > 0)
                {
                    itemList.SelectedIndex = 0;
                }
            }
        }