Dear Friends:
I am using MapXtreme 2008 With C# I have very basic problem I need to create text on a specific X,Y. I am reading and trying but not able to do it.
I am able to insert images on a specific X,Y but not text I am really embraced with this problem. can anyone help me.
please help me.
Regards:
Nabeel Ahmad.
please see the code
private void MapInfo_Geometry_LegacyText(double X1,double Y1, string MyText)
{
try
{
Feature ftr;
MapInfo.Geometry.CoordSysFactory factory = Session.Current.CoordSysFactory;
MapInfo.Geometry.CoordSys csysWGS84 = factory.CreateCoordSys("EPSG:4326");
double X2 = X1 + 0.01555;
double Y2 = Y1 - 0.00173;
DPoint pt = new MapInfo.Geometry.DPoint(X1, Y1);
MapInfo.Geometry.DRect rect = new MapInfo.Geometry.DRect(X1, Y1, X2, Y2);
MapInfo.Geometry.LegacyText ltxt = new MapInfo.Geometry.LegacyText(csysWGS84, rect, MyText);
double X = double.Parse(label_X.Text);
double Y = double.Parse(label_Y.Text);
TextFactory.CreateLegacyText(mapControl_Fs.Map.GetDisplayCoordSys(), pt, Alignment.TopCenter, label_INCIDENT_ID_1.Text, mapControl_Fs.Map, new MapInfo.Styles.Font("Microsoft Sans Serif", 20));
MapInfo.Geometry.FeatureGeometry g = new MapInfo.Geometry.Ellipse(csysWGS84, pt, 0.003, 0.003, DistanceUnit.Kilometer, DistanceType.Spherical);
MapInfo.Styles.SimpleInterior sis = new MapInfo.Styles.SimpleInterior(2, Color.Red);
MapInfo.Styles.LineWidth lw = new MapInfo.Styles.LineWidth(1, MapInfo.Styles.LineWidthUnit.Point);
MapInfo.Styles.SimpleLineStyle sl = new MapInfo.Styles.SimpleLineStyle(lw, 3, Color.Empty);
MapInfo.Styles.AreaStyle ar = new MapInfo.Styles.AreaStyle(sl, sis);
MapInfo.Styles.CompositeStyle cs = new MapInfo.Styles.CompositeStyle(ar, null, null, null);
MapInfo.Mapping.FeatureOverrideStyleModifier fsm = new MapInfo.Mapping.FeatureOverrideStyleModifier("a", cs);
MapInfo.Data.MIConnection conn = new MapInfo.Data.MIConnection();
MapInfo.Data.Table tbl;
conn.Open();
tbl = conn.Catalog.GetTable("tbl_PointAdd");
if (tbl != null)
conn.Catalog.CloseTable("tbl_PointAdd");
MapInfo.Data.TableInfoMemTable ti = new MapInfo.Data.TableInfoMemTable("tbl_PointAdd");
ti.Columns.Add(MapInfo.Data.ColumnFactory.CreateFeatureGeometryColumn(mapControl_Fs.Map.GetDisplayCoordSys()));
ti.Columns.Add(MapInfo.Data.ColumnFactory.CreateStyleColumn());
ti.Temporary = true;
tbl = conn.Catalog.CreateTable(ti);
MapInfo.Mapping.FeatureLayer lyr = new MapInfo.Mapping.FeatureLayer(tbl, "tbl_PointAnimation");
mapControl_Fs.Map.Layers.Add(lyr);
MapInfo.Data.MICommand cmd = conn.CreateCommand();
ftr = new MapInfo.Data.Feature(g, cs);
tbl.InsertFeature(ftr);
lyr.VolatilityHint = MapInfo.Mapping.LayerVolatilityHint.Animate;
lyr.Modifiers.Append(fsm);
conn.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.StackTrace.ToString());
}
}