?? texttool.cs
字號:
?// Copyright 2006 ESRI
//
// All rights reserved under the copyright laws of the United States
// and applicable international laws, treaties, and conventions.
//
// You may freely redistribute and use this sample code, with or
// without modification, provided you include the original copyright
// notice and use restrictions.
//
// See use restrictions at /arcgis/developerkit/userestrictions.
using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using ESRI.ArcGIS.ADF.Web.UI.WebControls;
using ESRI.ArcGIS.ADF.Web.UI.WebControls.Tools;
using ESRI.ArcGIS.ADF.ArcGISServer;
using ESRI.ArcGIS.ADF.Web.DataSources;
using ESRI.ArcGIS.Server;
using System.Collections;
using ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer;
public class TextTool: IMapServerCommandAction, IMapServerToolAction
{
#region IServerAction Members
void IServerAction.ServerAction(ToolbarItemInfo info)
{
ESRI.ArcGIS.ADF.Web.UI.WebControls.Map mapctrl = (ESRI.ArcGIS.ADF.Web.UI.WebControls.Map)info.BuddyControls[0];
MapFunctionality mf = (MapFunctionality)mapctrl.GetFunctionality(0);
ESRI.ArcGIS.ADF.ArcGISServer.MapDescription mapDescription = mf.MapDescription;
ESRI.ArcGIS.ADF.Web.Geometry.Point adf_map_point = ESRI.ArcGIS.ADF.Web.Geometry.Point.ToMapPoint(200, 200, mapctrl.Extent, mf.DisplaySettings.ImageDescriptor.Width, mf.DisplaySettings.ImageDescriptor.Height);
PointN ags_map_point = ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Converter.FromAdfPoint(adf_map_point);
TextElement text = new TextElement();
text.TextGeometry = ags_map_point;
TextSymbol textSymbol = new TextSymbol();
ESRI.ArcGIS.ADF.ArcGISServer.RgbColor rgb = new ESRI.ArcGIS.ADF.ArcGISServer.RgbColor();
rgb.Red = 0;
rgb.Green = 0;
rgb.Blue = 255;
rgb.AlphaValue = 255;
textSymbol.Color = rgb;
textSymbol.Size = 10;
textSymbol.FontName = "Arial";
text.Symbol = textSymbol;
text.Scale = true;
text.Text = "COMMAND";
if (mapDescription.CustomGraphics != null)
{
GraphicElement[] oldges = mapDescription.CustomGraphics;
int cnt = oldges.Length;
GraphicElement[] newges = new GraphicElement[cnt + 1];
oldges.CopyTo(newges, 0);
newges[cnt] = text;
mapDescription.CustomGraphics = newges;
}
else
{
GraphicElement[] ges = new GraphicElement[1];
ges[0] = text;
mapDescription.CustomGraphics = ges;
}
mapctrl.Refresh();
}
#endregion
#region IMapServerToolAction Members
public void ServerAction(ToolEventArgs args)
{
ESRI.ArcGIS.ADF.Web.UI.WebControls.Map mapctrl;
mapctrl = (ESRI.ArcGIS.ADF.Web.UI.WebControls.Map)args.Control;
PointEventArgs pea = (PointEventArgs)args;
System.Drawing.Point screen_point = pea.ScreenPoint;
MapFunctionality mf = (MapFunctionality)mapctrl.GetFunctionality(0);
ESRI.ArcGIS.ADF.ArcGISServer.MapDescription mapDescription = mf.MapDescription;
ESRI.ArcGIS.ADF.Web.Geometry.Point adf_map_point = ESRI.ArcGIS.ADF.Web.Geometry.Point.ToMapPoint(screen_point, mapctrl.Extent, mf.DisplaySettings.ImageDescriptor.Width, mf.DisplaySettings.ImageDescriptor.Height);
PointN ags_map_point = ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Converter.FromAdfPoint(adf_map_point);
TextElement text = new TextElement();
text.TextGeometry = ags_map_point;
TextSymbol textSymbol = new TextSymbol();
ESRI.ArcGIS.ADF.ArcGISServer.RgbColor rgb = new ESRI.ArcGIS.ADF.ArcGISServer.RgbColor();
rgb.Red = 255;
rgb.Green = 0;
rgb.Blue = 0;
rgb.AlphaValue = 255;
textSymbol.Color = rgb;
textSymbol.Size = 10;
textSymbol.FontName = "Tahoma";
text.Symbol = textSymbol;
text.Scale = true;
text.Text = "TOOL";
if (mapDescription.CustomGraphics != null)
{
GraphicElement[] oldges = mapDescription.CustomGraphics;
int cnt = oldges.Length;
GraphicElement[] newges = new GraphicElement[cnt + 1];
oldges.CopyTo(newges, 0);
newges[cnt] = text;
mapDescription.CustomGraphics = newges;
}
else
{
GraphicElement[] ges = new GraphicElement[1];
ges[0] = text;
mapDescription.CustomGraphics = ges;
}
mapctrl.Refresh();
}
#endregion
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -