Exemplo n.º 1
0
 /// <summary>
 /// Converts from MapScript color to System.Drawing.Color
 /// </summary>
 /// <param name="color">The object representing the color values to be converted.</param>
 /// <returns>The converted value</returns>
 public static Color MapColor2DrawingColor(colorObj color)
 {
     if (color.red >= 0 && color.green >= 0 && color.blue >= 0)
     {
         return Color.FromArgb(color.alpha, color.red, color.green, color.blue);
     }
     else return Color.Empty;
 }
Exemplo n.º 2
0
 internal static HandleRef getCPtrAndSetReference(colorObj obj, object parent) {
   if (obj != null)
   {
     obj.swigParentRef = parent;
     return obj.swigCPtr;
   }
   else
   {
     return new HandleRef(null, IntPtr.Zero);
   }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Converts from MapScript color to System.Drawing.Color
 /// </summary>
 /// <param name="color">The object representing the color values to be converted.</param>
 /// <returns>The converted value</returns>
 public static Color MapColor2DrawingColor(colorObj color)
 {
     if (color.red >= 0 && color.green >= 0 && color.blue >= 0)
     {
         return(Color.FromArgb(color.alpha, color.red, color.green, color.blue));
     }
     else
     {
         return(Color.Empty);
     }
 }
Exemplo n.º 4
0
 internal static HandleRef getCPtrAndDisown(colorObj obj, object parent) {
   if (obj != null)
   {
     obj.swigCMemOwn = false;
     obj.swigParentRef = parent;
     return obj.swigCPtr;
   }
   else
   {
     return new HandleRef(null, IntPtr.Zero);
   }
 }
Exemplo n.º 5
0
 /// <summary>
 /// Converts from System.Drawing.Color to MapScript color.
 /// </summary>
 /// <param name="color">The object representing the destination object.</param>
 /// <param name="source">The value to be converted from</param>
 public static void DrawingColor2MapColor(colorObj color, Color source)
 {
     if (source == Color.Empty)
     {
         color.red   = -1;
         color.green = -1;
         color.blue  = -1;
     }
     else
     {
         color.red   = source.R;
         color.green = source.G;
         color.blue  = source.B;
         color.alpha = source.A;
     }
 }
Exemplo n.º 6
0
 /// <summary>
 /// Converts from System.Drawing.Color to MapScript color.
 /// </summary>
 /// <param name="color">The object representing the destination object.</param>
 /// <param name="source">The value to be converted from</param>
 public static void DrawingColor2MapColor(colorObj color, Color source)
 {
     if (source == Color.Empty)
     {
         color.red = -1;
         color.green = -1;
         color.blue = -1;
     }
     else
     {
         color.red = source.R;
         color.green = source.G;
         color.blue = source.B;
         color.alpha = source.A;
     }
 }
Exemplo n.º 7
0
 internal static HandleRef getCPtr(colorObj obj) {
   return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
 }
Exemplo n.º 8
0
        /// <summary>
        /// Adding the selected layer to map
        /// </summary>
        void AddLayerToMap()
        {
            // trying to open the layer
            layerObj layer = new layerObj(map);
            layer.connection = textBoxServer.Text.Trim();
            layer.connectiontype = MS_CONNECTION_TYPE.MS_WMS;
            layer.type = MS_LAYER_TYPE.MS_LAYER_RASTER;
            layer.status = mapscript.MS_ON;

            // set up authentication
            NetworkCredential cred = (NetworkCredential)resolver.GetCredentials();
            if (cred != null)
            {
                layer.metadata.set("wms_auth_username", cred.UserName);
                layer.metadata.set("wms_auth_password", cred.Password);
                layer.metadata.set("wms_auth_type", "any");
            }
            WebProxy proxy = (WebProxy)resolver.Proxy;
            if (proxy != null)
            {
                layer.metadata.set("wms_proxy_host", proxy.Address.Host);
                layer.metadata.set("wms_proxy_port", proxy.Address.Port.ToString());
                layer.metadata.set("wms_proxy_auth_type", "any");
                layer.metadata.set("wms_proxy_type", resolver.ProxyType);
                cred = (NetworkCredential)resolver.GetProxyCredentials();
                if (cred != null)
                {
                    layer.metadata.set("wms_proxy_username", cred.UserName);
                    layer.metadata.set("wms_proxy_password", cred.Password);
                }
            }

            // setting up the selected layer
            selected = new MapObjectHolder(layer, target);

            // set queryable flag
            if (wms_queryable == "1")
                layer.template = "query.html";

            // setting up the layer metadata section
            layer.metadata.set("wms_name", wms_name);
            layer.metadata.set("wms_format", comboBoxImageFormat.Text.Trim());

            layer.metadata.set("wms_server_version", wms_server_version);

            if (!colorPickerLayerColor.Value.IsEmpty)
            {
                colorObj color = new colorObj(colorPickerLayerColor.Value.R,
                    colorPickerLayerColor.Value.G, colorPickerLayerColor.Value.B, 0);
                layer.metadata.set("wms_bgcolor", "0x" + color.toHex().Substring(1));
            }

            if (!checkBoxTransparent.Checked)
                layer.metadata.set("wms_transparent", "FALSE");

            // wms_style
            if (comboBoxStyle.Text != "")
                layer.metadata.set("wms_style", comboBoxStyle.Text);

            // title
            if (wms_title != null)
                layer.name = MapUtils.GetUniqueLayerName(map, wms_title, 0);
            else
                layer.name = MapUtils.GetUniqueLayerName(map, "Layer", 0);

            // scale denom
            if (wms_maxscaledenom > 0)
                layer.maxscaledenom = wms_maxscaledenom;
            if (wms_minscaledenom > 0)
                layer.maxscaledenom = wms_minscaledenom;

            // get bbox parameters
            if (wms_bbox != null && map.numlayers == 1)
            {
                // this is the first layer, set the extent of the map
                map.setExtent(wms_bbox.minx, wms_bbox.miny, wms_bbox.maxx, wms_bbox.maxy);
            }

            // setting up the selected projection
            KeyValuePair<string, string> current = (KeyValuePair<string, string>)bs.Current;
            string wms_srs = current.Key;

            // mapping not EPSG systems to the EPSG variants
            if (string.Compare(wms_srs, "CRS:84", true) == 0)
                wms_srs = "EPSG:4326";
            else if (string.Compare(wms_srs, "CRS:83", true) == 0)
                wms_srs = "EPSG:4369";
            else if (string.Compare(wms_srs, "CRS:27", true) == 0)
                wms_srs = "EPSG:4267";

            if (wms_srs.StartsWith("EPSG", StringComparison.InvariantCultureIgnoreCase))
                layer.metadata.set("wms_srs", wms_srs);
            layer.setProjection(wms_srs);
        }
Exemplo n.º 9
0
 /// <summary>
 /// Sets the value of the control according to the given object
 /// </summary>
 /// <param name="color">The object representing the color values to be set.</param>
 public void SetColor(colorObj color)
 {
     Value = MapColor2DrawingColor(color);
 }
Exemplo n.º 10
0
 /// <summary>
 /// Applies the selected color to the given object
 /// </summary>
 /// <param name="color">The object should be updated.</param>
 public void ApplyTo(colorObj color)
 {
     DrawingColor2MapColor(color, Value);
 }
Exemplo n.º 11
0
        /// <summary>
        /// Adding the selected layer to map
        /// </summary>
        void AddLayerToMap()
        {
            // trying to open the layer
            layerObj layer = new layerObj(map);

            layer.connection     = textBoxServer.Text.Trim();
            layer.connectiontype = MS_CONNECTION_TYPE.MS_WMS;
            layer.type           = MS_LAYER_TYPE.MS_LAYER_RASTER;
            layer.status         = mapscript.MS_ON;

            // set up authentication
            NetworkCredential cred = (NetworkCredential)resolver.GetCredentials();

            if (cred != null)
            {
                layer.metadata.set("wms_auth_username", cred.UserName);
                layer.metadata.set("wms_auth_password", cred.Password);
                layer.metadata.set("wms_auth_type", "any");
            }
            WebProxy proxy = (WebProxy)resolver.Proxy;

            if (proxy != null)
            {
                layer.metadata.set("wms_proxy_host", proxy.Address.Host);
                layer.metadata.set("wms_proxy_port", proxy.Address.Port.ToString());
                layer.metadata.set("wms_proxy_auth_type", "any");
                layer.metadata.set("wms_proxy_type", resolver.ProxyType);
                cred = (NetworkCredential)resolver.GetProxyCredentials();
                if (cred != null)
                {
                    layer.metadata.set("wms_proxy_username", cred.UserName);
                    layer.metadata.set("wms_proxy_password", cred.Password);
                }
            }

            // setting up the selected layer
            selected = new MapObjectHolder(layer, target);

            // set queryable flag
            if (wms_queryable == "1")
            {
                layer.template = "query.html";
            }

            // setting up the layer metadata section
            layer.metadata.set("wms_name", wms_name);
            layer.metadata.set("wms_format", comboBoxImageFormat.Text.Trim());

            layer.metadata.set("wms_server_version", wms_server_version);

            if (!colorPickerLayerColor.Value.IsEmpty)
            {
                colorObj color = new colorObj(colorPickerLayerColor.Value.R,
                                              colorPickerLayerColor.Value.G, colorPickerLayerColor.Value.B, 0);
                layer.metadata.set("wms_bgcolor", "0x" + color.toHex().Substring(1));
            }

            if (!checkBoxTransparent.Checked)
            {
                layer.metadata.set("wms_transparent", "FALSE");
            }

            // wms_style
            if (comboBoxStyle.Text != "")
            {
                layer.metadata.set("wms_style", comboBoxStyle.Text);
            }

            // title
            if (wms_title != null)
            {
                layer.name = MapUtils.GetUniqueLayerName(map, wms_title, 0);
            }
            else
            {
                layer.name = MapUtils.GetUniqueLayerName(map, "Layer", 0);
            }

            // scale denom
            if (wms_maxscaledenom > 0)
            {
                layer.maxscaledenom = wms_maxscaledenom;
            }
            if (wms_minscaledenom > 0)
            {
                layer.maxscaledenom = wms_minscaledenom;
            }

            // get bbox parameters
            if (wms_bbox != null && map.numlayers == 1)
            {
                // this is the first layer, set the extent of the map
                map.setExtent(wms_bbox.minx, wms_bbox.miny, wms_bbox.maxx, wms_bbox.maxy);
            }

            // setting up the selected projection
            KeyValuePair <string, string> current = (KeyValuePair <string, string>)bs.Current;
            string wms_srs = current.Key;

            // mapping not EPSG systems to the EPSG variants
            if (string.Compare(wms_srs, "CRS:84", true) == 0)
            {
                wms_srs = "EPSG:4326";
            }
            else if (string.Compare(wms_srs, "CRS:83", true) == 0)
            {
                wms_srs = "EPSG:4369";
            }
            else if (string.Compare(wms_srs, "CRS:27", true) == 0)
            {
                wms_srs = "EPSG:4267";
            }

            if (wms_srs.StartsWith("EPSG", StringComparison.InvariantCultureIgnoreCase))
            {
                layer.metadata.set("wms_srs", wms_srs);
            }
            layer.setProjection(wms_srs);
        }
Exemplo n.º 12
0
 /// <summary>
 /// Applies the selected color to the given object
 /// </summary>
 /// <param name="color">The object should be updated.</param>
 public void ApplyTo(colorObj color)
 {
     DrawingColor2MapColor(color, Value);
 }
Exemplo n.º 13
0
 /// <summary>
 /// Sets the value of the control according to the given object
 /// </summary>
 /// <param name="color">The object representing the color values to be set.</param>
 public void SetColor(colorObj color)
 {
     Value = MapColor2DrawingColor(color);
 }
Exemplo n.º 14
0
        /// <summary>
        /// show all the predefined symbols
        /// </summary>
        private void LoadSymbolFromLib()
        {
            classObj pClass = new classObj(null);
            styleObj pStyle = new styleObj(pClass);

            colorObj pColor = new colorObj(0,0,0,0);

            int iSymbolCount = m_pDefaultMap.getNumSymbols();

            symbolSetObj pSymSet = m_pDefaultMap.symbolset;

            for(int i=1;i < iSymbolCount;i++)
            {
                pStyle.symbol = i;
                pStyle.color = pColor;

                symbolObj pSymbol = pSymSet.getSymbol(i);

                if (m_LayerType == MS_LAYER_TYPE.MS_LAYER_POINT)
                {
                    //type cartoline if only for line type
                    if (pSymbol.type == (int)MS_SYMBOL_TYPE.MS_SYMBOL_CARTOLINE)
                        continue;

                    pStyle.size = 10;
                    pStyle.angle = 0;
                }
                else if (m_LayerType == MS_LAYER_TYPE.MS_LAYER_LINE)
                {
                    pStyle.size = 6;
                    pStyle.width = 1;
                }
                else if (m_LayerType == MS_LAYER_TYPE.MS_LAYER_POLYGON)
                {
                    //type cartoline if only for line type
                    if (pSymbol.type == (int)MS_SYMBOL_TYPE.MS_SYMBOL_CARTOLINE)
                        continue;

                    pStyle.size = 8;
                    pStyle.outlinewidth = 1;
                    pStyle.outlinecolor = pColor;
                }

                imageListPreview.Images.Add(GetImageFromClass(pClass, 48, 48));

                listViewSymbol.Items.Add(pSymbol.name, imageListPreview.Images.Count - 1);
            }

            pStyle.Dispose();
            pClass.Dispose();
            pColor.Dispose();
        }