本文整理汇总了C#中Map.AddSymdef方法的典型用法代码示例。如果您正苦于以下问题:C# Map.AddSymdef方法的具体用法?C# Map.AddSymdef怎么用?C# Map.AddSymdef使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Map
的用法示例。
在下文中一共展示了Map.AddSymdef方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateSymDef
protected override SymDef CreateSymDef(Map map, SymColor symColor)
{
Glyph glyph = new Glyph();
SymPath path = new SymPath(ScaleCoords((PointF[]) coords1.Clone()), kinds1);
glyph.AddLine(symColor, path, NormalCourseAppearance.lineThickness * scaleRatio * appearance.lineWidth, LineJoin.Round, LineCap.Round);
path = new SymPath(ScaleCoords((PointF[]) coords2.Clone()), kinds2);
glyph.AddLine(symColor, path, NormalCourseAppearance.lineThickness * scaleRatio * appearance.lineWidth, LineJoin.Round, LineCap.Round);
path = new SymPath(ScaleCoords((PointF[]) coords3.Clone()), kinds3);
glyph.AddLine(symColor, path, NormalCourseAppearance.lineThickness * scaleRatio * appearance.lineWidth, LineJoin.Round, LineCap.Round);
path = new SymPath(ScaleCoords((PointF[]) coords4.Clone()), kinds4);
glyph.AddLine(symColor, path, NormalCourseAppearance.lineThickness * scaleRatio * appearance.lineWidth, LineJoin.Round, LineCap.Round);
glyph.ConstructionComplete();
PointSymDef symdef = new PointSymDef("Refreshment point", "713", glyph, false);
symdef.ToolboxImage = MapUtil.CreateToolboxIcon(Properties.Resources.Water_OcadToolbox);
map.AddSymdef(symdef);
return symdef;
}
示例2: CreateSymdef
// Create a point symbol that can be used to put this symbol onto a map inside
// a box of the given size (in mm).
public PointSymDef CreateSymdef(Map map, SymColor color, float boxSize)
{
Glyph glyph = new Glyph();
for (int i = 0; i < strokes.Length; ++i)
strokes[i].AddToMapGlyph(glyph, color, boxSize);
glyph.ConstructionComplete();
// Find a free OCAD ID number.
string symbolId = map.GetFreeSymbolId(800);
// Create the symdef
PointSymDef symdef;
symdef = new PointSymDef("Description: " + this.GetName(Util.CurrentLangName()), symbolId, glyph, false);
// Create the toolbox image.
Bitmap bm = new Bitmap(24, 24);
using (Graphics g = Graphics.FromImage(bm)) {
g.Clear(Color.White);
g.SmoothingMode = SmoothingMode.AntiAlias;
if (kind >= 'T') {
g.SetClip(new RectangleF(0, 0, bm.Width / 2, bm.Height));
Draw(g, Color.Black, new RectangleF(0, bm.Height / 3F, bm.Width * 8F / 3F, bm.Height / 3F));
g.SetClip(new RectangleF(bm.Width / 2, 0, bm.Width / 2, bm.Height));
Draw(g, Color.Black, new RectangleF(- bm.Width * 5F / 3F, bm.Height / 3F, bm.Width * 8F / 3F, bm.Height / 3F));
}
else {
Draw(g, Color.Black, new RectangleF(0, 0, bm.Width, bm.Height));
}
}
symdef.ToolboxImage = MapUtil.CreateToolboxIcon(bm);
// Add the symdef to the map.
map.AddSymdef(symdef);
return symdef;
}
示例3: CreateLineSpecialSymDef
// This is used by both line and rectangle specials.
public static SymDef CreateLineSpecialSymDef(Map map, SymColor symColor, LineKind lineKind, float lineWidth, float gapSize, float dashSize, LineJoin lineJoin, LineCap lineCap)
{
string symbolId = map.GetFreeSymbolId(901);
LineSymDef symdef;
switch (lineKind) {
case LineKind.Single:
symdef = new LineSymDef("Line", symbolId, symColor, lineWidth, lineJoin, lineCap);
break;
case LineKind.Double:
LineSymDef.DoubleLineInfo doubleInfo = new LineSymDef.DoubleLineInfo();
doubleInfo.doubleLeftColor = doubleInfo.doubleRightColor = symColor;
doubleInfo.doubleThick = gapSize;
doubleInfo.doubleLeftWidth = doubleInfo.doubleRightWidth = lineWidth;
symdef = new LineSymDef("Line", symbolId, null, 0, lineJoin, lineCap);
symdef.SetDoubleLines(doubleInfo);
break;
case LineKind.Dashed:
LineSymDef.DashInfo dashInfo = new LineSymDef.DashInfo();
dashInfo.dashLength = dashInfo.firstDashLength = dashInfo.lastDashLength = dashSize;
dashInfo.gapLength = gapSize;
symdef = new LineSymDef("Line", symbolId, symColor, lineWidth, lineJoin, lineCap);
symdef.SetDashInfo(dashInfo);
break;
default: throw new ApplicationException("Unexpected line kind");
}
symdef.ToolboxImage = MapUtil.CreateToolboxIcon(Properties.Resources.LineSpecial_OcadToolbox);
map.AddSymdef(symdef);
return symdef;
}
示例4: 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;
}
示例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;
}