当前位置: 首页>>代码示例>>C#>>正文


C# Map.Read方法代码示例

本文整理汇总了C#中Map.Read方法的典型用法代码示例。如果您正苦于以下问题:C# Map.Read方法的具体用法?C# Map.Read怎么用?C# Map.Read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Map的用法示例。


在下文中一共展示了Map.Read方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CoordinateMapper

        public CoordinateMapper(Map map)
        {
            if (map == null)
                throw new Exception(MiscText.GpxMustBeOcadMap);

            using (map.Read()) {
                mapScale = map.MapScale;
                realWorldCoords = map.RealWorldCoords;

                if (!realWorldCoords.RealWorldOn && realWorldCoords.RealWorldAngle == 0 && realWorldCoords.RealWorldOffsetX == 0 && realWorldCoords.RealWorldOffsetY == 0) {
                    hasRealWorldCoords = false;
                    mapProjectionType = MapProjectionType.None;
                }
                else {
                    hasRealWorldCoords = true;
                    mapProjectionType = realWorldCoords.ProjectionType;
                    if (mapProjectionType == MapProjectionType.Known) {
                        SetupProjection(realWorldCoords.Proj4String);
                    }
                }

            }
        }
开发者ID:petergolde,项目名称:PurplePen,代码行数:23,代码来源:GpxFile.cs

示例2: FindPurpleByName

        public void FindPurpleByName()
        {
            Map map = new Map(new GDIPlus_TextMetrics(), null);
            using (map.Write()) {
                map.AddColor("Purple 50%", 14, 0, 0.5F, 0, 0, false);
                map.AddColor("Purple", 11, 0.2F, 1F, 0.1F, 0.08F, false);
                map.AddColor("Blue", 12, 0.95F, 0.35F, 0, 0, false);
                map.AddColor("Purplatci", 18, 0, 1F, 0, 0, false);
                map.AddColor("Black", 88, 0, 0, 0, 1F, false);
            }

            short ocadId;
            float c, m, y, k;
            List<SymColor> colorList;
            using (map.Read())
                colorList = new List<SymColor>(map.AllColors);

            Assert.IsTrue(FindPurple.FindPurpleColor(colorList, out ocadId, out c, out m, out y, out k));
            Assert.AreEqual(11, ocadId);
            Assert.AreEqual(0.2F, c);
            Assert.AreEqual(1F, m);
            Assert.AreEqual(0.1F, y);
            Assert.AreEqual(0.08F, k);
        }
开发者ID:petergolde,项目名称:PurplePen,代码行数:24,代码来源:FindPurpleTests.cs

示例3: RenderToMapThenToBitmap

        // Render a description to a map, then to a bitmap for testing purposes. Hardcoded 6 mm box size.
        internal static Bitmap RenderToMapThenToBitmap(SymbolDB symbolDB, DescriptionLine[] description, DescriptionKind kind, int numColumns)
        {
            DescriptionRenderer descriptionRenderer = new DescriptionRenderer(symbolDB);
            descriptionRenderer.Description = description;
            descriptionRenderer.DescriptionKind = kind;
            descriptionRenderer.CellSize = 6.0F;
            descriptionRenderer.Margin = 0.7F;
            descriptionRenderer.NumberOfColumns = numColumns;
            PointF location = new PointF(30, -100);

            SizeF size = descriptionRenderer.Measure();

            Bitmap bm = new Bitmap((int) size.Width * 8, (int) size.Height * 8);
            Graphics g = Graphics.FromImage(bm);
            g.ScaleTransform(bm.Width / size.Width, -bm.Height / size.Height);
            g.TranslateTransform(-location.X, -location.Y);

            g.Clear(Color.White);

            Map map = new Map(new GDIPlus_TextMetrics(), null);
            using (map.Write()) {
                Dictionary<object, SymDef> dict = new Dictionary<object, SymDef>();

                // Create white color and white-out symdef.
                SymColor white = map.AddColorBottom("White", 44, 0, 0, 0, 0, false);
                AreaSymDef whiteArea = new AreaSymDef("White out", "890", white, null);
                whiteArea.ToolboxImage = MapUtil.CreateToolboxIcon(Properties.Resources.WhiteOut_OcadToolbox);
                map.AddSymdef(whiteArea);
                dict[CourseLayout.KeyWhiteOut] = whiteArea;

                SymColor color = map.AddColor("Purple", 11, 0.045F, 0.59F, 0, 0.255F, false);
                descriptionRenderer.RenderToMap(map, color, location, dict);
            }

            InputOutput.WriteFile(TestUtil.GetTestFile("descriptions\\desc_temp.ocd"), map, new MapFileFormat(MapFileFormatKind.OCAD, 8));

            using (map.Read()) {
                RenderOptions renderOpts = new RenderOptions();
                renderOpts.usePatternBitmaps = true;
                renderOpts.minResolution = 0.1F;
                renderOpts.renderTemplates = RenderTemplateOption.MapAndTemplates;
                map.Draw(new GDIPlus_GraphicsTarget(g), new RectangleF(location.X, location.Y - size.Height, size.Width, size.Height), renderOpts, null);
            }

            g.Dispose();

            return bm;
        }
开发者ID:petergolde,项目名称:PurplePen,代码行数:49,代码来源:DescriptionRendererTests.cs

示例4: NoPurple

        public void NoPurple()
        {
            Map map = new Map(new GDIPlus_TextMetrics(), null);
            using (map.Write()) {
                map.AddColor("Yellow", 11, 0.0F, 0.25F, 0.79F, 0.08F, false);
                map.AddColor("Blue", 12, 0.95F, 0.35F, 0, 0, false);
                map.AddColor("Black", 88, 0, 0, 0, 1F, false);
            }

            short ocadId;
            float c, m, y, k;
            List<SymColor> colorList;
            using (map.Read())
                colorList = new List<SymColor>(map.AllColors);

            Assert.IsFalse(FindPurple.FindPurpleColor(colorList, out ocadId, out c, out m, out y, out k));
        }
开发者ID:petergolde,项目名称:PurplePen,代码行数:17,代码来源:FindPurpleTests.cs

示例5: ValidateMapFile

        // Validate the map file to make sure it is readable. If OK, return true and set the scale.
        // If not OK, return false and set the error message.
        public static bool ValidateMapFile(string mapFileName, out float scale, out float dpi, out Size bitmapSize, out RectangleF mapBounds, out MapType mapType, out string errorMessageText)
        {
            scale = 0; dpi = 0;
            mapType = MapType.None;
            bitmapSize = new Size();
            string fileExtension = Path.GetExtension(mapFileName);

            if (string.Compare(fileExtension, ".pdf", StringComparison.InvariantCultureIgnoreCase) == 0) {
                if (ValidatePdf(mapFileName, out dpi, out bitmapSize, out errorMessageText) != null) {
                    mapType = MapType.PDF;
                    mapBounds = new RectangleF(0, 0, (float)bitmapSize.Width / dpi * 25.4F, (float) bitmapSize.Height / dpi * 25.4F);
                    return true;
                }
                else {
                    mapBounds = new RectangleF();
                    return false;
                }
            }

            Map map = new Map(TextMetricsProvider, new GDIPlus_FileLoader(Path.GetDirectoryName(mapFileName)));

            try {
                InputOutput.ReadFile(mapFileName, map);
            }
            catch (Exception e) {
                // Didn't load as an OCAD file. If it has a non-OCD/OpenMapper extension, try loading as an image.
                if ((string.Compare(fileExtension, ".ocd", StringComparison.InvariantCultureIgnoreCase) != 0) &&
                    (string.Compare(fileExtension, ".omap", StringComparison.InvariantCultureIgnoreCase) != 0) &&
                    (string.Compare(fileExtension, ".xmap", StringComparison.InvariantCultureIgnoreCase) != 0))
                {
                    try {
                        Bitmap bitmap = (Bitmap) Image.FromFile(mapFileName);
                        bitmapSize = bitmap.Size;
                        dpi = bitmap.HorizontalResolution;
                        bitmap.Dispose();
                        mapType = MapType.Bitmap;
                        mapBounds = new RectangleF(0, 0, (float)bitmapSize.Width / dpi * 25.4F, (float)bitmapSize.Height / dpi * 25.4F);
                        errorMessageText = "";
                        return true;
                    }
                    catch {
                        // Wasn't an bitmap file either.
                        errorMessageText = string.Format(MiscText.CannotReadImageFile, mapFileName);
                        mapBounds = new RectangleF();
                        return false;
                    }
                }

                errorMessageText = string.Format(MiscText.CannotReadMap, e.Message);
                mapBounds = new RectangleF();
                return false;
            }

            using (map.Read())
            {
                scale = map.MapScale;
                mapBounds = map.Bounds;
            }

            errorMessageText = "";
            mapType = MapType.OCAD;
            return true;
        }
开发者ID:petergolde,项目名称:PurplePen,代码行数:65,代码来源:MapUtil.cs

示例6: CreateOcadFiles

        // Create some courses, write them, and check against a dump.
        void CreateOcadFiles(OcadCreationSettings settings, string[] expectedOcadFiles, params RectangleF[] expectedPrintRectangles)
        {
            for (int i = 0; i < expectedOcadFiles.Length; ++i) {
                File.Delete(expectedOcadFiles[i]);
            }

            bool success = controller.CreateOcadFiles(settings);
            Assert.IsTrue(success);

            for (int i = 0; i < expectedOcadFiles.Length; ++i) {
                Map newMap = new Map(new GDIPlus_TextMetrics(), null);
                using (newMap.Write())
                    InputOutput.ReadFile(expectedOcadFiles[i], newMap);
                using (newMap.Read())
                    TestUtil.AssertEqualRect(expectedPrintRectangles[i], newMap.PrintArea, 0.01F, "ocad imported print area");
            }
        }
开发者ID:petergolde,项目名称:PurplePen,代码行数:18,代码来源:SetPrintAreaTests.cs


注:本文中的Map.Read方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。