Controls commands environment


Purpose
This sample demonstrates changing the symbols used by the out-of-the-box New Marker, Line, Freehand, Rectangle, and Polygon element tools. By default, these tools use a black symbol (and a yellow fill where appropriate). The default symbols can be changed by updating the properties of the CommandsEnvironment singleton object. The sample uses the SymbologyControl in conjunction with the PageLayoutControl, ToolbarControl, and the controls commands. The properties on the IGraphicProperties interface are used by the controls commands to manage default symbology.
 
This sample has been developed on a machine with a display screen resolution of 96 dots per inch (dpi). This sample also contains code that will correctly scale the ArcGIS Engine controls when run at a resolution of 120 dpi. This issue is discussed in detail in the Workaround for controls display issues in 96 versus 120 dpi topic.

How to use

See How to use ArcGIS samples for help on compiling, setting up the debugger, and running the sample. If the sample has associated data, you will find that the sample's zip file includes a "data" folder alongside the language folders. However, you will need to update the sample to point to the location of the data once you have extracted all the files.

  1. Load a map document into the PageLayoutControl.
  2. Add elements to the display using the commands on the ToolbarControl.
  3. Right-click the display to add a text element containing today's date.
  4. Change the application default symbol properties using the combo box and the items displayed in the SymbologyControl.
  5. Repeat steps 2 and 4 if desired.

Additional information

The LoadStyleFile method is used within the Form_Load event to add the contents of ESRI.ServerStyle into the SymbologyControl. A new ServerStyleGalleryItem is created with its name set to myStyle and its item set to the MarkerSymbol, LineSymbol, FillSymbol, and TextSymbol properties on the IGraphicProperties interface. ServerStyleGalleryItem is added to the appropriate StyleClass using the ISymbologyStyleClass.AddItem method.
 
A combo box is populated with marker, line, fill, and text symbol items. The SelectedIndexChanged event of the combo box is used to set the type of items displayed in the SymbologyControl using the StyleClass property. Clicking an item displayed in the SymbologyControl fires OnItemSelectedEvent. The IStyleGalleryItem.Item property is used to determine whether the item implements IMarkerSymbol, ILineSymbol, IFillSymbol, or ITextSymbol; and either the MarkerSymbol, LineSymbol, FillSymbol, or TextSymbol property on the IGraphicProperties interface is set.
 
The IPageLayoutControlEvents.OnMouseDown event is used to create a new TextElement. The Text property is set to today's date and the Symbol property is set to IGraphicsProperties.TextSymbol. The element is added to the GraphicsContainer using the IPageLayoutControl.AddElement method.


AssemblyInfo.cs Assembly information.
CommandsEnvironment.cs Form file.
Download the C# files
AssemblyInfo.vb Assembly information.
CommandsEnvironment.vb Form file.
Download the VB.NET files

Download the files for all languages

See Also:

CommandsEnvironment class
IGraphicProperties interface
Workaround for controls display issues in 96 versus 120 dpi




Development licensing Deployment licensing
Engine Developer Kit Engine Runtime
ArcView
ArcEditor
ArcInfo