Ejemplo n.º 1
0
        // Set the map file used to draw.
        public void SetMapFile(MapType newMapType, string newFilename)
        {
            this.mapType  = newMapType;
            this.filename = newFilename;
            this.bitmap   = null;
            this.map      = null;

            if (newMapType == MapType.None)
            {
                map        = null;
                mapVersion = new MapFileFormat(MapFileFormatKind.None, 0);
                bitmap     = null;
                pdfMapFile = null;
            }
            else if (newMapType == MapType.OCAD)
            {
                map        = new Map(MapUtil.TextMetricsProvider, new GDIPlus_FileLoader(Path.GetDirectoryName(newFilename)));
                mapVersion = InputOutput.ReadFile(newFilename, map);
                bitmap     = null;
                pdfMapFile = null;
            }
            else if (newMapType == MapType.Bitmap)
            {
                map        = null;
                mapVersion = new MapFileFormat(MapFileFormatKind.None, 0);
                Bitmap bm = (Bitmap)Image.FromFile(newFilename);
                bitmap     = new GDIPlus_Bitmap(bm);
                bitmapDpi  = bm.HorizontalResolution;
                pdfMapFile = null;
            }
            else if (newMapType == MapType.PDF)
            {
                string errorText;
                map        = null;
                mapVersion = new MapFileFormat(MapFileFormatKind.None, 0);
                Size bitmapSize;
                pdfMapFile = MapUtil.ValidatePdf(newFilename, out bitmapDpi, out bitmapSize, out errorText);
                if (pdfMapFile == null)
                {
                    this.mapType = MapType.None;
                    bitmap       = null;
                }
                else
                {
                    Bitmap bm = (Bitmap)Image.FromFile(pdfMapFile.PngFileName);
                    bitmap = new GDIPlus_Bitmap(bm);
                }
            }
            else
            {
                Debug.Fail("bad maptype");
            }

            UpdateDimmedBitmap();
            RaiseChanged(null);        // redraw everything.
        }
Ejemplo n.º 2
0
        // Set the map file used to draw.
        public void SetMapFile(MapType newMapType, string newFilename)
        {
            this.mapType = newMapType;
            this.filename = newFilename;
            this.bitmap = null;
            this.map = null;

            if (newMapType == MapType.None) {
                map = null;
                mapVersion = new MapFileFormat(MapFileFormatKind.None, 0);
                bitmap = null;
                pdfMapFile = null;
            }
            else if (newMapType == MapType.OCAD) {
                map = new Map(MapUtil.TextMetricsProvider, new GDIPlus_FileLoader(Path.GetDirectoryName(newFilename)));
                mapVersion = InputOutput.ReadFile(newFilename, map);
                bitmap = null;
                pdfMapFile = null;
            }
            else if (newMapType == MapType.Bitmap) {
                map = null;
                mapVersion = new MapFileFormat(MapFileFormatKind.None, 0);
                Bitmap bm = (Bitmap)Image.FromFile(newFilename);
                bitmap = new GDIPlus_Bitmap(bm);
                bitmapDpi = bm.HorizontalResolution;
                pdfMapFile = null;
            }
            else if (newMapType == MapType.PDF) {
                string errorText;
                map = null;
                mapVersion = new MapFileFormat(MapFileFormatKind.None, 0);
                Size bitmapSize;
                pdfMapFile = MapUtil.ValidatePdf(newFilename, out bitmapDpi, out bitmapSize, out errorText);
                if (pdfMapFile == null) {
                    this.mapType = MapType.None;
                    bitmap = null;
                }
                else {
                    Bitmap bm = (Bitmap)Image.FromFile(pdfMapFile.PngFileName);
                    bitmap = new GDIPlus_Bitmap(bm);
                }
            }
            else {
                Debug.Fail("bad maptype");
            }

            UpdateDimmedBitmap();
            RaiseChanged(null);        // redraw everything.
        }