static void doc_PrintPage(object sender, PrintPageEventArgs e)
    {
        // Create the output format
        outputFormatObj of = new outputFormatObj("CAIRO/WINGDIPRINT", "cairowinGDIPrint");

        map.appendOutputFormat(of);
        map.selectOutputFormat("cairowinGDIPrint");
        map.resolution = e.Graphics.DpiX;
        Console.WriteLine("map resolution = " + map.resolution.ToString() + "DPI  defresolution = " + map.defresolution.ToString() + " DPI");
        // Calculating the desired image size to cover the entire area;
        map.width  = Convert.ToInt32(e.PageBounds.Width * e.Graphics.DpiX / 100);
        map.height = Convert.ToInt32(e.PageBounds.Height * e.Graphics.DpiY / 100);

        Console.WriteLine("map size = " + map.width.ToString() + " * " + map.height.ToString() + " pixels");

        IntPtr hdc = e.Graphics.GetHdc();

        try
        {
            // Attach the device to the outputformat for drawing
            of.attachDevice(hdc);
            // Drawing directly to the GDI context
            using (imageObj image = map.draw()) { };
        }
        finally
        {
            of.attachDevice(IntPtr.Zero);
            e.Graphics.ReleaseHdc(hdc);
        }

        e.HasMorePages = false;
    }
Beispiel #2
0
    public static void Main(string[] args)
    {
        Console.WriteLine("");
        if (args.Length < 2)
        {
            usage();
        }

        mapObj map = new mapObj(args[0]);

        Console.WriteLine("# Map layers " + map.numlayers + "; Map name = " + map.name);
        for (int i = 0; i < map.numlayers; i++)
        {
            Console.WriteLine("Layer [" + i + "] name: " + map.getLayer(i).name);
        }

        try
        {
            // Create the output format
            outputFormatObj of = new outputFormatObj("CAIRO/WINGDI", "cairowinGDI");
            map.appendOutputFormat(of);
            map.selectOutputFormat("cairowinGDI");

            Bitmap mapImage = new Bitmap(map.width, map.height, PixelFormat.Format32bppRgb);

            using (Graphics g = Graphics.FromImage(mapImage))
            {
                IntPtr hdc = g.GetHdc();
                try
                {
                    // Attach the device to the outputformat for drawing
                    of.attachDevice(hdc);
                    // Drawing directly to the GDI context
                    using (imageObj image = map.draw()) { };
                }
                finally
                {
                    of.attachDevice(IntPtr.Zero);
                    g.ReleaseHdc(hdc);
                }
            }

            mapImage.Save(args[1]);
        }
        catch (Exception ex)
        {
            Console.WriteLine("\nMessage ---\n{0}", ex.Message);
            Console.WriteLine(
                "\nHelpLink ---\n{0}", ex.HelpLink);
            Console.WriteLine("\nSource ---\n{0}", ex.Source);
            Console.WriteLine(
                "\nStackTrace ---\n{0}", ex.StackTrace);
            Console.WriteLine(
                "\nTargetSite ---\n{0}", ex.TargetSite);
        }
    }
 internal static HandleRef getCPtrAndSetReference(outputFormatObj obj, object parent) {
   if (obj != null)
   {
     obj.swigParentRef = parent;
     return obj.swigCPtr;
   }
   else
   {
     return new HandleRef(null, IntPtr.Zero);
   }
 }
Beispiel #4
0
    public void testimageObj()
    {
        mapObj          map    = new mapObj(mapfile);
        imageObj        image  = map.draw();
        outputFormatObj format = image.format;

        format.setOption("INTERLACE", "OFF");

        map = null;
        gc();
        assert(format.getOption("INTERLACE", "") == "OFF", "testimageObj");
    }
  public static void Main(string[] args)
  {
    Console.WriteLine("");
	if (args.Length < 2) usage();
    
	mapObj map = new mapObj(args[0]);

    Console.WriteLine("# Map layers " + map.numlayers + "; Map name = " + map.name);
    for (int i = 0; i < map.numlayers; i++) 
	{
        Console.WriteLine("Layer [" + i + "] name: " + map.getLayer(i).name);
	}

    try
    {
        // Create the output format
        outputFormatObj of = new outputFormatObj("CAIRO/WINGDI", "cairowinGDI");
        map.appendOutputFormat(of);
        map.selectOutputFormat("cairowinGDI");

        Bitmap mapImage = new Bitmap(map.width, map.height, PixelFormat.Format32bppRgb);

        using (Graphics g = Graphics.FromImage(mapImage))
        {
            IntPtr hdc = g.GetHdc();
            try
            {
                // Attach the device to the outputformat for drawing
                of.attachDevice(hdc);
                // Drawing directly to the GDI context
                using (imageObj image = map.draw()) { };
            }
            finally
            {
                of.attachDevice(IntPtr.Zero);
                g.ReleaseHdc(hdc);
            }
        }

        mapImage.Save(args[1]);
    } 
	catch (Exception ex) 
	{
                Console.WriteLine( "\nMessage ---\n{0}", ex.Message );
                Console.WriteLine( 
                    "\nHelpLink ---\n{0}", ex.HelpLink );
                Console.WriteLine( "\nSource ---\n{0}", ex.Source );
                Console.WriteLine( 
                    "\nStackTrace ---\n{0}", ex.StackTrace );
                Console.WriteLine( 
                    "\nTargetSite ---\n{0}", ex.TargetSite );	}	
  }
 internal static HandleRef getCPtr(outputFormatObj obj) {
   return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
 }
    static void doc_PrintPage(object sender, PrintPageEventArgs e)
    {
        // Create the output format
        outputFormatObj of = new outputFormatObj("CAIRO/WINGDIPRINT", "cairowinGDIPrint");
        map.appendOutputFormat(of);
        map.selectOutputFormat("cairowinGDIPrint");
        map.resolution = e.Graphics.DpiX;
        Console.WriteLine("map resolution = " + map.resolution.ToString() + "DPI  defresolution = " + map.defresolution.ToString() + " DPI");
        // Calculating the desired image size to cover the entire area; 
        map.width = Convert.ToInt32(e.PageBounds.Width * e.Graphics.DpiX / 100);
        map.height = Convert.ToInt32(e.PageBounds.Height * e.Graphics.DpiY / 100);

        Console.WriteLine("map size = " + map.width.ToString() + " * " + map.height.ToString() + " pixels");

        IntPtr hdc = e.Graphics.GetHdc();
        try
        {
            // Attach the device to the outputformat for drawing
            of.attachDevice(hdc);
            // Drawing directly to the GDI context
            using (imageObj image = map.draw()) { };
        }
        finally
        {
            of.attachDevice(IntPtr.Zero);
            e.Graphics.ReleaseHdc(hdc);
        }

        e.HasMorePages = false;
    }
Beispiel #8
0
        /// <summary>
        /// Refresh the controls according to the underlying object.
        /// </summary>
        public void RefreshView()
        {
            if (map == null)
            {
                return;
            }
            // general tab
            this.textBoxName.Text      = map.name;
            this.textBoxShapePath.Text = map.shapepath;
            this.textBoxImagepath.Text = map.web.imagepath;
            this.textBoxSymbolset.Text = map.symbolset.filename;
            this.textBoxFontset.Text   = map.fontset.filename;
            // image details tab
            this.colorPickerBackColor.SetColor(map.imagecolor);
            comboBoxImageType.Items.Clear();
            comboBoxImageType.Items.AddRange(new object[] { "png", "jpeg", "gif", "png8", "png24", "pdf", "svg", "cairopng"
                                                            , "GTiff", "kml", "kmz" });

            for (int i = 0; i < map.numoutputformats; i++)
            {
                outputFormatObj format = map.getOutputFormat(i);
                if (!comboBoxImageType.Items.Contains(format.name))
                {
                    comboBoxImageType.Items.Add(format.name);
                }
            }

            //outputFormatObj[] formats = map.outputformatlist;
            //for (int i = 0; i < formats.Length; i++)
            //{
            //    if (!comboBoxImageType.Items.Contains(formats[i].name))
            //        comboBoxImageType.Items.Add(formats[i].name);
            //}
            comboBoxImageType.SelectedItem = map.imagetype;
            this.textBoxResolution.Text    = map.resolution.ToString();

            // setting up the projection information
            this.textBoxProjection.Tag  = map.getProjection();
            this.textBoxProjection.Text = "";
            string key = map.getFirstMetaDataKey();

            while (key != null)
            {
                if (key == "coordsys_name")
                {
                    this.textBoxProjection.Text = map.getMetaData("coordsys_name");
                    break;
                }
                key = map.getNextMetaDataKey(key);
            }
            if (this.textBoxProjection.Text == "")
            {
                string proj4;
                int    epsg;
                this.textBoxProjection.Text = MapUtils.FindProjection(this.textBoxProjection.Tag.ToString(), out proj4, out epsg);
            }

            comboBoxUnits.DataSource   = Enum.GetValues(typeof(MS_UNITS));
            comboBoxUnits.SelectedItem = (MS_UNITS)map.units;

            checkBoxTransparent.Checked = (map.outputformat.transparent == mapscript.MS_TRUE && map.outputformat.imagemode == (int)MS_IMAGEMODE.MS_IMAGEMODE_RGBA);
            checkBoxTransparent.Enabled = (map.outputformat.imagemode == (int)MS_IMAGEMODE.MS_IMAGEMODE_RGB || map.outputformat.imagemode == (int)MS_IMAGEMODE.MS_IMAGEMODE_RGBA);

            // extent tab
            UpdateExtentValues();

            SetDirty(false);
        }
Beispiel #9
0
        public void Parse(string contents, bool ignoreVersion)
        {
            string fontsetPath   = Application.StartupPath + "\\templates\\font.list";
            string symbolsetPath = Application.StartupPath + "\\templates\\symbols.sym";
            string path          = "";

            StringBuilder outputformat = new StringBuilder();

            mapObj template = null;

            if (File.Exists(Application.StartupPath + "\\templates\\new.map"))
            {
                template = new mapObj(Application.StartupPath + "\\templates\\new.map");

                fontsetPath   = template.fontset.filename;
                symbolsetPath = template.symbolset.filename;
            }
            else
            {
                template = new mapObj(null);
                template.setSymbolSet(symbolsetPath);
                template.setFontSet(fontsetPath);
            }

            string mapfileContents = contents.ToUpper(); // for string comparison
            string fonts           = File.ReadAllText(fontsetPath);

            using (StringReader r = new StringReader(contents))
            {
                string line;
                int    lineNumber           = 0;
                int    groupStartLineNumber = 0;
                while ((line = r.ReadLine()) != null)
                {
                    ++lineNumber;
                    // replace trailing \" with \\"
                    if (line != Regex.Replace(line, "(?<=[^\\\\])\\\\\"\\s*\\Z", "\\\\\""))
                    {
                        line = Regex.Replace(line, "(?<=[^\\\\])\\\\\"\\s*\\Z", "\\\\\"");
                        AppendLog("Escape trailing \\\" chars ", lineNumber);
                    }

                    string[] values = line.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
                    string   key;
                    if (values.Length > 0)
                    {
                        key = values[0].ToUpper();
                    }
                    else
                    {
                        key = "";
                    }

                    if (!IsExpressionKeyword(path + "\\" + key))
                    {
                        if (Regex.IsMatch(line, "[^\\\\]\\\\[^\\\\]"))
                        {
                            // escape single backslashes for non expressions
                            line = line.Replace("\\", "\\\\");
                            AppendLog("Escape \\ characters ", lineNumber);
                        }
                    }
                    else if (IsTextExpressionKeyword(path + "\\" + key))
                    {
                        int    pos = line.IndexOf(key) + key.Length + 1;
                        string val = line.Substring(pos).Trim();

                        AppendLog("Review Class Text/Expression: " + val, lineNumber);

                        // trying to identify the expression
                        //if (Regex.IsMatch(val, @"\(.*\)"))
                        //{
                        //    // MS_EXPRESSION
                        //    AppendLog("Modify expression to string (please review!): " + val, lineNumber);
                        //    line = line.Substring(0, pos) + "\"" + val.Substring(1, val.Length - 2) + "\"";
                        //}
                        //else if (Regex.IsMatch(val, @"\/[^\/]*\/"))
                        //{
                        //    // MS_REGEX
                        //    AppendLog("Modify regex expression to string (please review!): " + val, lineNumber);
                        //    line = line.Substring(0, pos) + "\"" + val.Substring(1, val.Length - 2) + "\"";
                        //}
                    }

                    // set up path of the node
                    foreach (string s in groupkeywords)
                    {
                        if ((path + "\\" + key) == s)
                        {
                            groupStartLineNumber = lineNumber;
                            path = s;
                            break;
                        }
                    }

                    if (key == "END" && path.LastIndexOf('\\') > 0)
                    {
                        if (path == "\\MAP\\OUTPUTFORMAT")
                        {
                            if (outputformat.ToString().Contains("PC256"))
                            {
                                AppendLog("Remove deprecated outputformat with IMAGEMODE PC256", groupStartLineNumber, lineNumber);
                            }
                            else
                            {
                                output.AppendLine(outputformat.ToString());
                                output.AppendLine(line);
                            }
                            path = path.Substring(0, path.LastIndexOf('\\'));
                            continue;
                        }
                        path = path.Substring(0, path.LastIndexOf('\\'));
                    }

                    // Test elements
                    if (path == "\\MAP\\OUTPUTFORMAT")
                    {
                        if (key == "OUTPUTFORMAT")
                        {
                            outputformat.Length = 0;
                        }

                        outputformat.AppendLine(line);
                    }
                    else if (key == "FONTSET" && line.Substring(line.IndexOf("FONTSET") + 8).ToUpper().Trim(new char[] { '\'', '\"', ' ' }) != fontsetPath.ToUpper().Replace("\\", "\\\\"))
                    {
                        AppendLog("Upgrade fontset location", lineNumber);
                        output.AppendLine("  FONTSET \"" + fontsetPath.Replace("\\", "\\\\") + "\"");
                    }
                    else if (key == "SYMBOLSET" && line.Substring(line.IndexOf("SYMBOLSET") + 10).ToUpper().Trim(new char[] { '\'', '\"', ' ' }) != symbolsetPath.ToUpper().Replace("\\", "\\\\"))
                    {
                        AppendLog("Upgrade symbolset location", lineNumber);
                        output.AppendLine("  SYMBOLSET \"" + symbolsetPath.Replace("\\", "\\\\") + "\"");
                    }
                    else if (key == "RESOLUTION" && !mapfileContents.Contains("DEFRESOLUTION "))
                    {
                        output.AppendLine(line);
                        AppendLog("Add DEFRESOLUTION " + values[1], lineNumber);
                        output.AppendLine("  DEFRESOLUTION " + values[1]);
                    }
                    else if (key == "MAP")
                    {
                        output.AppendLine(line); // add MAP
                    }
                    else if (key == "IMAGETYPE")
                    {
                        List <string> f = new List <string>(new string[] { "png", "jpeg", "gif", "png8", "png24", "pdf", "svg", "cairopng", "gtiff", "kml", "kmz" });

                        //outputFormatObj[] formats = template.outputformatlist;
                        //for (int i = 0; i < formats.Length; i++)
                        //{
                        //    if (!f.Contains(formats[i].name))
                        //        f.Add(formats[i].name);
                        //}
                        for (int i = 0; i < template.numoutputformats; i++)
                        {
                            outputFormatObj format = template.getOutputFormat(i);
                            if (!f.Contains(format.name))
                            {
                                f.Add(format.name);
                            }
                        }

                        string imageType = values[1].Trim(new char[] { '\'', '\"' }).ToLower();
                        if (!f.Contains(imageType))
                        {
                            AppendLog("Change image type: " + imageType + " -> png", lineNumber);
                            output.AppendLine("  IMAGETYPE png");
                        }
                        else
                        {
                            output.AppendLine(line);
                        }
                    }
                    else if (key == "BACKGROUNDCOLOR" && (path == "\\MAP\\LAYER\\CLASS\\LABEL" || path == "\\MAP\\SCALEBAR\\LABEL"))
                    {
                        AppendLog("Remove label BACKGROUNDCOLOR " + values[1], lineNumber);
                    }
                    else if (key == "BACKGROUNDSHADOWCOLOR" && (path == "\\MAP\\LAYER\\CLASS\\LABEL" || path == "\\MAP\\SCALEBAR\\LABEL"))
                    {
                        AppendLog("Remove label BACKGROUNDSHADOWCOLOR " + values[1], lineNumber);
                    }
                    else if (key == "BACKGROUNDSHADOWSIZE" && (path == "\\MAP\\LAYER\\CLASS\\LABEL" || path == "\\MAP\\SCALEBAR\\LABEL"))
                    {
                        AppendLog("Remove label BACKGROUNDSHADOWSIZE " + values[1], lineNumber);
                    }
                    else if (!ignoreVersion && key == "\"MAPMANAGER_VERSION\"" && path == "\\MAP\\WEB\\METADATA" && values[1].Trim(new char[] { '\'', '\"' }).StartsWith("1.0"))
                    {
                        changelog.Length = 0; // no upgrading required
                        return;
                    }
                    else if (key == "DRIVER" && path == "\\MAP\\OUTPUTFORMAT")
                    {
                        List <string> drivers = new List <string>(new string[] { "GD/PC256", "GD/GIF", "GD/PNG", "AGG/PNG8", "AGG/PNG", "AGG/JPEG", "CAIRO/PNG", "CAIRO/JPEG", "CAIRO/PDF", "CAIRO/SVG", "OGL/PNG", "KML", "KMZ" });

                        string driverName = values[1].Trim(new char[] { '\'', '\"' }).ToUpper();
                        if (driverName.StartsWith("GDAL/") || driverName.StartsWith("/OGR") || drivers.Contains(driverName))
                        {
                            output.AppendLine(line);
                        }
                        else
                        {
                            AppendLog("Change OUTPUTFORMAT/DRIVER " + values[1] + " -> AGG/PNG", lineNumber);
                            output.AppendLine("  DRIVER \"AGG/PNG\"");
                        }
                    }
                    else if ((key == "PATTERN" || key == "POSITION" || key == "GAP" || key == "LINECAP" || key == "LINEJOIN" || key == "LINEJOINMAXSIZE") && path == "\\MAP\\SYMBOL")
                    {
                        AppendLog("Remove " + key + " from the SYMBOL section", lineNumber);
                    }
                    else if (key == "FONT" && path == "\\MAP\\LAYER\\CLASS\\LABEL")
                    {
                        if (!fonts.Contains(values[1].Trim(new char[] { '\'', '\"' }).ToLower()))
                        {
                            AppendLog("Change missing font " + values[1] + " to arial", lineNumber);
                            output.AppendLine("  FONT \"arial\"");
                        }
                        else
                        {
                            output.AppendLine(line); // no change done
                        }
                    }
                    else if (key == "LABELANGLEITEM" && path == "\\MAP\\LAYER")
                    {
                        AppendLog("Remove LABELANGLEITEM " + values[1], lineNumber);
                    }
                    else if (key == "LABELSIZEITEM" && path == "\\MAP\\LAYER")
                    {
                        AppendLog("Remove LABELSIZEITEM " + values[1], lineNumber);
                    }
                    else if (key == "SYMBOL" && path == "\\MAP\\LAYER\\CLASS\\STYLE")
                    {
                        string symbolName    = values[1].Trim(new char[] { '\'', '\"' }).ToLower();
                        String newSymbolName = symbolName;
                        if (symbolName == "grenze2")
                        {
                            newSymbolName = "Rectangle";
                        }
                        else if (symbolName == "ellipse-flach")
                        {
                            newSymbolName = "Ellipse";
                        }
                        else if (symbolName == "dreieck")
                        {
                            newSymbolName = "Triangle";
                        }
                        else if (symbolName == "zelt")
                        {
                            newSymbolName = "Tent";
                        }
                        else if (symbolName == "quadrat")
                        {
                            newSymbolName = "Square";
                        }
                        else if (symbolName == "kreuz1")
                        {
                            newSymbolName = "Cross";
                        }
                        else if (symbolName == "kreuz1")
                        {
                            newSymbolName = "Cross";
                        }
                        else if (symbolName == "kreuz2")
                        {
                            newSymbolName = "Cross-2";
                        }
                        else if (symbolName == "kreuz4")
                        {
                            newSymbolName = "Cross-3";
                        }
                        else if (symbolName == "haus")
                        {
                            newSymbolName = "House";
                        }
                        else if (symbolName == "sechseck")
                        {
                            newSymbolName = "Hexagon";
                        }
                        else if (symbolName == "stern")
                        {
                            newSymbolName = "Star";
                        }
                        else if (symbolName == "MapInfo-Pen-3")
                        {
                            newSymbolName = "Dot-1";
                        }
                        else if (symbolName == "MapInfo-Pen-4")
                        {
                            newSymbolName = "Dash-1";
                        }
                        else if (symbolName == "MapInfo-Pen-5")
                        {
                            newSymbolName = "Dash-2";
                        }
                        else if (symbolName == "MapInfo-Pen-6")
                        {
                            newSymbolName = "Dash-3";
                        }
                        else if (symbolName == "MapInfo-Pen-7")
                        {
                            newSymbolName = "Dash-5";
                        }
                        else if (symbolName == "MapInfo-Pen-9")
                        {
                            newSymbolName = "Dash-7";
                        }
                        else if (symbolName == "MapInfo-Pen-10")
                        {
                            newSymbolName = "Dash-6";
                        }
                        else if (symbolName == "MapInfo-Pen-11")
                        {
                            newSymbolName = "Dash-7";
                        }
                        else if (symbolName == "MapInfo-Pen-12")
                        {
                            newSymbolName = "Dash-8";
                        }
                        else if (symbolName == "MapInfo-Pen-13")
                        {
                            newSymbolName = "Dash-9";
                        }
                        else if (symbolName == "MapInfo-Pen-14")
                        {
                            newSymbolName = "DotDash-2";
                        }
                        else if (symbolName == "MapInfo-Pen-15")
                        {
                            newSymbolName = "DotDash-2";
                        }
                        else if (symbolName == "MapInfo-Pen-16")
                        {
                            newSymbolName = "DashDash-1";
                        }
                        else if (symbolName == "MapInfo-Pen-18")
                        {
                            newSymbolName = "DotDash-2";
                        }
                        else if (symbolName == "MapInfo-Pen-19")
                        {
                            newSymbolName = "DotDash-2";
                        }
                        else if (symbolName == "MapInfo-Pen-20")
                        {
                            newSymbolName = "DoubleDotDash-1";
                        }
                        else if (symbolName == "MapInfo-Pen-21")
                        {
                            newSymbolName = "DoubleDotDash-2";
                        }
                        else if (symbolName == "MapInfo-Pen-22")
                        {
                            newSymbolName = "DoubleDotDash-2";
                        }
                        else if (symbolName == "MapInfo-Pen-23")
                        {
                            newSymbolName = "DotDash-1";
                        }
                        else if (symbolName == "MapInfo-Pen-24")
                        {
                            newSymbolName = "DoubleDotDash-1";
                        }
                        else if (symbolName == "MapInfo-Pen-25")
                        {
                            newSymbolName = "DotDash-1";
                        }
                        else if (symbolName == "MapInfo-Brush-3")
                        {
                            newSymbolName = "Horizontal-1";
                        }
                        else if (symbolName == "MapInfo-Brush-4")
                        {
                            newSymbolName = "Vertical-1";
                        }
                        else if (symbolName == "MapInfo-Brush-5")
                        {
                            newSymbolName = "RightDiag-1";
                        }
                        else if (symbolName == "MapInfo-Brush-6")
                        {
                            newSymbolName = "LeftDiag-1";
                        }
                        else if (symbolName == "MapInfo-Brush-7")
                        {
                            newSymbolName = "Grid-1";
                        }
                        else if (symbolName == "MapInfo-Brush-8")
                        {
                            newSymbolName = "GridDiag-1";
                        }
                        else if (symbolName == "MapInfo-Brush-15")
                        {
                            newSymbolName = "LeftDiag-1";
                        }
                        else if (symbolName == "MapInfo-Brush-19")
                        {
                            newSymbolName = "Horizontal-1";
                        }
                        else if (symbolName == "MapInfo-Brush-20")
                        {
                            newSymbolName = "Horizontal-2";
                        }
                        else if (symbolName == "MapInfo-Brush-21")
                        {
                            newSymbolName = "Horizontal-1";
                        }
                        else if (symbolName == "MapInfo-Brush-22")
                        {
                            newSymbolName = "Horizontal-1";
                        }
                        else if (symbolName == "MapInfo-Brush-23")
                        {
                            newSymbolName = "Horizontal-1";
                        }
                        else if (symbolName == "MapInfo-Brush-26")
                        {
                            newSymbolName = "Vertical-1";
                        }
                        else if (symbolName == "MapInfo-Brush-27")
                        {
                            newSymbolName = "Vertical-1";
                        }
                        else if (symbolName == "MapInfo-Brush-28")
                        {
                            newSymbolName = "Vertical-1";
                        }
                        else if (symbolName == "MapInfo-Brush-29")
                        {
                            newSymbolName = "RightDiag-1";
                        }
                        else if (symbolName == "MapInfo-Brush-30")
                        {
                            newSymbolName = "RightDiag-1";
                        }
                        else if (symbolName == "MapInfo-Brush-31")
                        {
                            newSymbolName = "RightDiag-1";
                        }
                        else if (symbolName == "MapInfo-Brush-32")
                        {
                            newSymbolName = "RightDiag-1";
                        }
                        else if (symbolName == "MapInfo-Brush-34")
                        {
                            newSymbolName = "LeftDiag-1";
                        }
                        else if (symbolName == "MapInfo-Brush-35")
                        {
                            newSymbolName = "LeftDiag-1";
                        }
                        else if (symbolName == "MapInfo-Brush-36")
                        {
                            newSymbolName = "LeftDiag-1";
                        }
                        else if (symbolName == "MapInfo-Brush-37")
                        {
                            newSymbolName = "LeftDiag-1";
                        }
                        else if (symbolName == "MapInfo-Brush-39")
                        {
                            newSymbolName = "Grid-1";
                        }
                        else if (symbolName == "MapInfo-Brush-40")
                        {
                            newSymbolName = "Grid-2";
                        }
                        else if (symbolName == "MapInfo-Brush-41")
                        {
                            newSymbolName = "Grid-1";
                        }
                        else if (symbolName == "MapInfo-Brush-42")
                        {
                            newSymbolName = "Grid-2";
                        }
                        else if (symbolName == "MapInfo-Brush-43")
                        {
                            newSymbolName = "Grid-1";
                        }
                        else if (symbolName == "MapInfo-Brush-44")
                        {
                            newSymbolName = "GridDiag-1";
                        }
                        else if (symbolName == "MapInfo-Brush-45")
                        {
                            newSymbolName = "GridDiag-2";
                        }
                        else if (symbolName == "MapInfo-Brush-46")
                        {
                            newSymbolName = "GridDiag-1";
                        }
                        else if (symbolName == "MapInfo-Brush-47")
                        {
                            newSymbolName = "Ticks-1";
                        }
                        else if (symbolName == "MapInfo-Brush-51")
                        {
                            newSymbolName = "Ticks-1";
                        }
                        else if (symbolName == "MapInfo-Brush-63")
                        {
                            newSymbolName = "Dots-2";
                        }
                        else if (symbolName == "MapInfo-Brush-70")
                        {
                            newSymbolName = "Dots-1";
                        }
                        else if (symbolName == "MapInfo-Brush-137")
                        {
                            newSymbolName = "Dots-2";
                        }
                        if (MapLibrary.MapUtils.FindSymbol(template.symbolset, newSymbolName) == null)
                        {
                            int symbolIndex;
                            if (int.TryParse(newSymbolName, out symbolIndex))
                            {
                                // remove symbol when symbol was 0 - no symbol
                                if (symbolIndex == 0)
                                {
                                    AppendLog("Remove symbol with name: " + symbolName, lineNumber);
                                    continue;
                                }
                            }
                            newSymbolName = "default-marker";
                        }

                        if (symbolName != newSymbolName)
                        {
                            AppendLog("Rename symbol reference: " + symbolName + " -> " + newSymbolName, lineNumber);
                            output.AppendLine("  SYMBOL \'" + newSymbolName + "\'");
                        }
                    }
                    else
                    {
                        output.AppendLine(line); // not change done
                    }
                }
            }
        }
Beispiel #10
0
        /// <summary>
        /// Refresh the controls according to the underlying object.
        /// </summary>
        public void RefreshView()
        {
            listView.Items.Clear();

            if (map != null)
            {
                // setting up the icon background colors createLegendIcon
                // will take over the legend imagecolor setting from the map object
                int red   = map.legend.imagecolor.red;
                int green = map.legend.imagecolor.green;
                int blue  = map.legend.imagecolor.blue;
                map.legend.imagecolor.red   = this.BackColor.R;
                map.legend.imagecolor.green = this.BackColor.G;
                map.legend.imagecolor.blue  = this.BackColor.B;
                listView.BackColor          = this.BackColor;

                using (outputFormatObj format = map.outputformat)
                {
                    string imageType = null;
                    if ((format.renderer != mapscript.MS_RENDER_WITH_GD &&
                         format.renderer != mapscript.MS_RENDER_WITH_AGG) ||
                        string.Compare(format.mimetype.Trim(), "image/vnd.wap.wbmp", true) == 0 ||
                        string.Compare(format.mimetype.Trim(), "image/tiff", true) == 0 ||
                        string.Compare(format.mimetype.Trim(), "image/jpeg", true) == 0)
                    {
                        // falling back to the png type in case of the esoteric or bad looking types
                        imageType = map.imagetype;
                        map.selectOutputFormat("png24");
                    }

                    imageList.Images.Clear();
                    imageList.ImageSize = new Size(30, 20);

                    try
                    {
                        for (int i = 0; i < map.numlayers; i++)
                        {
                            layerObj layer = map.getLayer(i);
                            if (layer.status != mapscript.MS_OFF)
                            {
                                resultObj res;
                                shapeObj  feature;
                                using (resultCacheObj results = layer.getResults())
                                {
                                    if (results != null && results.numresults > 0)
                                    {
                                        // creating the icon for this layer
                                        using (classObj def_class = new classObj(null)) // for drawing legend images
                                        {
                                            using (imageObj image = def_class.createLegendIcon(map, layer, 30, 20))
                                            {
                                                // drawing the class icons
                                                layer.getClass(0).drawLegendIcon(map, layer, 20, 10, image, 5, 5);
                                                byte[] img = image.getBytes();
                                                using (MemoryStream ms = new MemoryStream(img))
                                                {
                                                    imageList.Images.Add(Image.FromStream(ms));
                                                }
                                            }
                                        }

                                        // extracting the features found
                                        for (int j = 0; j < results.numresults; j++)
                                        {
                                            res     = results.getResult(j);
                                            feature = layer.getShape(res);
                                            if (feature != null)
                                            {
                                                ListViewItem item = new ListViewItem(layer.name, imageList.Images.Count - 1);
                                                item.SubItems.Add(feature.index.ToString());
                                                item.SubItems.Add(MapUtils.GetShapeTypeName((MS_SHAPE_TYPE)feature.type));
                                                listView.Items.Add(item);

                                                StringBuilder s = new StringBuilder("");
                                                s.AppendLine("Feature Properties:");
                                                for (int k = 0; k < layer.numitems; k++)
                                                {
                                                    s.Append(layer.getItem(k));
                                                    s.Append(" = ");
                                                    s.AppendLine(feature.getValue(k));
                                                }
                                                item.Tag = s.ToString();
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    finally
                    {
                        // switch back to the original type
                        if (imageType != null)
                        {
                            map.selectOutputFormat(imageType);
                        }
                        // restoring the original legend backgroundcolor
                        map.legend.imagecolor.red   = red;
                        map.legend.imagecolor.green = green;
                        map.legend.imagecolor.blue  = blue;
                    }

                    listView.SmallImageList = imageList;
                }
                if (listView.Items.Count > 0)
                {
                    listView.Items[0].Selected = true;
                }
                else
                {
                    richTextBox.Text = "";
                }
            }
        }
 public int appendOutputFormat(outputFormatObj format) {
   int ret = mapscriptPINVOKE.mapObj_appendOutputFormat(swigCPtr, outputFormatObj.getCPtr(format));
   if (mapscriptPINVOKE.SWIGPendingException.Pending) throw mapscriptPINVOKE.SWIGPendingException.Retrieve();
   return ret;
 }
 public void setOutputFormat(outputFormatObj format) {
   mapscriptPINVOKE.mapObj_setOutputFormat(swigCPtr, outputFormatObj.getCPtr(format));
   if (mapscriptPINVOKE.SWIGPendingException.Pending) throw mapscriptPINVOKE.SWIGPendingException.Retrieve();
 }
 public imageObj(int width, int height, outputFormatObj input_format, string file, double resolution, double defresolution) : this(mapscriptPINVOKE.new_imageObj(width, height, outputFormatObj.getCPtr(input_format), file, resolution, defresolution), true, null) {
   if (mapscriptPINVOKE.SWIGPendingException.Pending) throw mapscriptPINVOKE.SWIGPendingException.Retrieve();
 }
 public imageObj getImage(outputFormatObj input_format) {
   IntPtr cPtr = mapscriptPINVOKE.symbolObj_getImage(swigCPtr, outputFormatObj.getCPtr(input_format));
   imageObj ret = (cPtr == IntPtr.Zero) ? null : new imageObj(cPtr, true, ThisOwn_true());
   if (mapscriptPINVOKE.SWIGPendingException.Pending) throw mapscriptPINVOKE.SWIGPendingException.Retrieve();
   return ret;
 }