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


C# Map.AddColor方法代码示例

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


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

示例1: 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

示例2: 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

示例3: RenderSymbolToMap

        // Test for rendering into a map.
        // Render one course object to a map.
        internal Map RenderSymbolToMap(Symbol sym, float boxSize)
        {
            Map map = new Map(new GDIPlus_TextMetrics(), null);

            using (map.Write()) {
                //Dictionary<object, SymDef> dict = new Dictionary<object, SymDef>();
                SymColor symColor = map.AddColor("Purple", 11, 0.045F, 0.59F, 0, 0.255F, false);
                PointSymDef symdef = sym.CreateSymdef(map, symColor, boxSize);
                PointSymbol symbol = new PointSymbol(symdef, new PointF(0,0), 0, null);
                map.AddSymbol(symbol);
            }
            return map;
        }
开发者ID:petergolde,项目名称:PurplePen,代码行数:15,代码来源:SymbolDBTests.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: RenderCourseObjToMap

        // Render one course object to a map.
        internal Map RenderCourseObjToMap(CourseObj courseobj)
        {
            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;

                // Create layout symdef.
                ImageSymDef layoutSymDef = new ImageSymDef(SymLayer.Layout);
                map.AddSymdef(layoutSymDef);
                dict[CourseLayout.KeyLayout] = layoutSymDef;

                SymColor symColor = null;
                SpecialColor specialColor = courseobj.CustomColor ?? SpecialColor.Purple;
                switch (specialColor.Kind) {
                    case SpecialColor.ColorKind.Black:
                        symColor = map.AddColor("Black", 1, 0, 0, 0, 1F, false);
                        break;
                    case SpecialColor.ColorKind.Purple:
                        symColor = map.AddColor("Purple", 11, 0.045F, 0.59F, 0, 0.255F, false);
                        break;
                    case SpecialColor.ColorKind.Custom:
                        CmykColor cmyk = specialColor.CustomColor;
                        symColor = map.AddColor("Custom", 61, cmyk.Cyan, cmyk.Magenta, cmyk.Yellow, cmyk.Black, false);
                        break;
                }

                courseobj.AddToMap(map, symColor, dict);

                // Make drop targets visible for debugging.
                foreach (SymDef symdef in map.AllSymdefs) {
                    if (symdef.SymbolId == "781")
                        map.SetSymdefVisible(symdef, true);
                }
            }
            return map;
        }
开发者ID:petergolde,项目名称:PurplePen,代码行数:45,代码来源:CourseObjTests.cs


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