About the Add map surrounds using the SymbologyControl Sample
[C#]
AddMapSurrounds.cs
using System; using System.Windows.Forms; using ESRI.ArcGIS.Controls; using ESRI.ArcGIS.SystemUI; using ESRI.ArcGIS; namespace AddMapSurrounds { public class AddMapSurrounds : System.Windows.Forms.Form { internal System.Windows.Forms.Label Label2; internal System.Windows.Forms.Label Label1; private ESRI.ArcGIS.Controls.AxLicenseControl axLicenseControl1; private ESRI.ArcGIS.Controls.AxToolbarControl axToolbarControl1; private ESRI.ArcGIS.Controls.AxTOCControl axTOCControl1; private ESRI.ArcGIS.Controls.AxPageLayoutControl axPageLayoutControl1; private System.ComponentModel.Container components = null; public AddMapSurrounds() { InitializeComponent(); } protected override void Dispose( bool disposing ) { //Release COM objects ESRI.ArcGIS.ADF.COMSupport.AOUninitialize.Shutdown(); if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AddMapSurrounds)); this.Label2 = new System.Windows.Forms.Label(); this.Label1 = new System.Windows.Forms.Label(); this.axLicenseControl1 = new ESRI.ArcGIS.Controls.AxLicenseControl(); this.axToolbarControl1 = new ESRI.ArcGIS.Controls.AxToolbarControl(); this.axTOCControl1 = new ESRI.ArcGIS.Controls.AxTOCControl(); this.axPageLayoutControl1 = new ESRI.ArcGIS.Controls.AxPageLayoutControl(); ((System.ComponentModel.ISupportInitialize)(this.axLicenseControl1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.axToolbarControl1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.axTOCControl1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.axPageLayoutControl1)).BeginInit(); this.SuspendLayout(); // // Label2 // this.Label2.Location = new System.Drawing.Point(627, 83); this.Label2.Name = "Label2"; this.Label2.Size = new System.Drawing.Size(153, 31); this.Label2.TabIndex = 6; this.Label2.Text = "2) Use the palette to add map surrounds onto the page"; // // Label1 // this.Label1.Location = new System.Drawing.Point(627, 42); this.Label1.Name = "Label1"; this.Label1.Size = new System.Drawing.Size(153, 32); this.Label1.TabIndex = 5; this.Label1.Text = "1) Load a map document into the PageLayoutControl. "; // // axLicenseControl1 // this.axLicenseControl1.Enabled = true; this.axLicenseControl1.Location = new System.Drawing.Point(627, 125); this.axLicenseControl1.Name = "axLicenseControl1"; this.axLicenseControl1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axLicenseControl1.OcxState"))); this.axLicenseControl1.Size = new System.Drawing.Size(32, 32); this.axLicenseControl1.TabIndex = 7; // // axToolbarControl1 // this.axToolbarControl1.Location = new System.Drawing.Point(7, 7); this.axToolbarControl1.Name = "axToolbarControl1"; this.axToolbarControl1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axToolbarControl1.OcxState"))); this.axToolbarControl1.Size = new System.Drawing.Size(773, 28); this.axToolbarControl1.TabIndex = 8; // // axTOCControl1 // this.axTOCControl1.Location = new System.Drawing.Point(7, 42); this.axTOCControl1.Name = "axTOCControl1"; this.axTOCControl1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axTOCControl1.OcxState"))); this.axTOCControl1.Size = new System.Drawing.Size(180, 450); this.axTOCControl1.TabIndex = 9; // // axPageLayoutControl1 // this.axPageLayoutControl1.Location = new System.Drawing.Point(193, 42); this.axPageLayoutControl1.Name = "axPageLayoutControl1"; this.axPageLayoutControl1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axPageLayoutControl1.OcxState"))); this.axPageLayoutControl1.Size = new System.Drawing.Size(428, 450); this.axPageLayoutControl1.TabIndex = 10; // // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(792, 498); this.Controls.Add(this.axPageLayoutControl1); this.Controls.Add(this.axTOCControl1); this.Controls.Add(this.axToolbarControl1); this.Controls.Add(this.axLicenseControl1); this.Controls.Add(this.Label2); this.Controls.Add(this.Label1); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.Name = "Form1"; this.Text = "Add Map Surrounds"; this.Load += new System.EventHandler(this.Form1_Load); ((System.ComponentModel.ISupportInitialize)(this.axLicenseControl1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.axToolbarControl1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.axTOCControl1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.axPageLayoutControl1)).EndInit(); this.ResumeLayout(false); } #endregion [STAThread] static void Main() { if (!RuntimeManager.Bind(ProductCode.Engine)) { if (!RuntimeManager.Bind(ProductCode.Desktop)) { MessageBox.Show("Unable to bind to ArcGIS runtime. Application will be shut down."); return; } } Application.Run(new AddMapSurrounds()); } private void Form1_Load(object sender, System.EventArgs e) { //Set buddy control axToolbarControl1.SetBuddyControl(axPageLayoutControl1); axTOCControl1.SetBuddyControl(axPageLayoutControl1); //Add ToolbarControl items axToolbarControl1.AddItem("esriControls.ControlsOpenDocCommand", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl1.AddItem("esriControls.ControlsPageZoomInTool", 0, -1, true, 0, esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl1.AddItem("esriControls.ControlsPageZoomOutTool", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl1.AddItem("esriControls.ControlsPageZoomWholePageCommand", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl1.AddItem("esriControls.ControlsMapZoomInTool", 0, -1, true, 0, esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl1.AddItem("esriControls.ControlsMapZoomOutTool", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl1.AddItem("esriControls.ControlsMapPanTool", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl1.AddItem("esriControls.ControlsMapFullExtentCommand", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl1.AddItem("esriControls.ControlsSelectTool", 0, -1, true, 0, esriCommandStyles.esriCommandStyleIconOnly); //Create a new ToolbarPalette IToolbarPalette toolbarPalette = new ToolbarPalette(); toolbarPalette.Caption = "Map Surrounds"; toolbarPalette.AddItem(new CreateNorthArrow(), -1, -1); toolbarPalette.AddItem(new CreateScaleBar(), -1, -1); toolbarPalette.AddItem(new CreateScaleText(), -1, -1); //Add the ToolbarPalette to the ToolbarControl axToolbarControl1.AddItem(toolbarPalette, -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly); } } }
[Visual Basic .NET]
AddMapSurrounds.vb
Imports ESRI.ArcGIS.Controls Imports ESRI.ArcGIS.SystemUI Imports ESRI.ArcGIS Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'Load runtime If Not RuntimeManager.Bind(ProductCode.Engine) Then If Not RuntimeManager.Bind(ProductCode.Desktop) Then MessageBox.Show("Unable to bind to ArcGIS runtime. Application will be shut down.") System.Environment.Exit(1) ' Force exit or other indication in the application End If End If 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) 'Release COM objects ESRI.ArcGIS.ADF.COMSupport.AOUninitialize.Shutdown() If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents AxToolbarControl1 As ESRI.ArcGIS.Controls.AxToolbarControl Friend WithEvents AxPageLayoutControl1 As ESRI.ArcGIS.Controls.AxPageLayoutControl Friend WithEvents AxLicenseControl1 As ESRI.ArcGIS.Controls.AxLicenseControl Friend WithEvents Label1 As System.Windows.Forms.Label Friend WithEvents Label2 As System.Windows.Forms.Label Friend WithEvents AxTOCControl1 As ESRI.ArcGIS.Controls.AxTOCControl <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(Form1)) Me.AxToolbarControl1 = New ESRI.ArcGIS.Controls.AxToolbarControl Me.AxPageLayoutControl1 = New ESRI.ArcGIS.Controls.AxPageLayoutControl Me.AxLicenseControl1 = New ESRI.ArcGIS.Controls.AxLicenseControl Me.Label1 = New System.Windows.Forms.Label Me.Label2 = New System.Windows.Forms.Label Me.AxTOCControl1 = New ESRI.ArcGIS.Controls.AxTOCControl CType(Me.AxToolbarControl1, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.AxPageLayoutControl1, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.AxLicenseControl1, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.AxTOCControl1, System.ComponentModel.ISupportInitialize).BeginInit() Me.SuspendLayout() ' 'AxToolbarControl1 ' Me.AxToolbarControl1.Location = New System.Drawing.Point(8, 8) Me.AxToolbarControl1.Name = "AxToolbarControl1" Me.AxToolbarControl1.OcxState = CType(resources.GetObject("AxToolbarControl1.OcxState"), System.Windows.Forms.AxHost.State) Me.AxToolbarControl1.Size = New System.Drawing.Size(764, 28) Me.AxToolbarControl1.TabIndex = 0 ' 'AxPageLayoutControl1 ' Me.AxPageLayoutControl1.Location = New System.Drawing.Point(193, 40) Me.AxPageLayoutControl1.Name = "AxPageLayoutControl1" Me.AxPageLayoutControl1.OcxState = CType(resources.GetObject("AxPageLayoutControl1.OcxState"), System.Windows.Forms.AxHost.State) Me.AxPageLayoutControl1.Size = New System.Drawing.Size(419, 468) Me.AxPageLayoutControl1.TabIndex = 1 ' 'AxLicenseControl1 ' Me.AxLicenseControl1.Enabled = True Me.AxLicenseControl1.Location = New System.Drawing.Point(618, 124) Me.AxLicenseControl1.Name = "AxLicenseControl1" Me.AxLicenseControl1.OcxState = CType(resources.GetObject("AxLicenseControl1.OcxState"), System.Windows.Forms.AxHost.State) Me.AxLicenseControl1.Size = New System.Drawing.Size(32, 32) Me.AxLicenseControl1.TabIndex = 2 ' 'Label1 ' Me.Label1.Location = New System.Drawing.Point(618, 47) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(154, 32) Me.Label1.TabIndex = 3 Me.Label1.Text = "1) Load a map document into the PageLayoutControl. " ' 'Label2 ' Me.Label2.Location = New System.Drawing.Point(618, 87) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size(154, 32) Me.Label2.TabIndex = 4 Me.Label2.Text = "2) Use the palette to add map surrounds onto the page" ' 'AxTOCControl1 ' Me.AxTOCControl1.Location = New System.Drawing.Point(7, 42) Me.AxTOCControl1.Name = "AxTOCControl1" Me.AxTOCControl1.OcxState = CType(resources.GetObject("AxTOCControl1.OcxState"), System.Windows.Forms.AxHost.State) Me.AxTOCControl1.Size = New System.Drawing.Size(180, 466) Me.AxTOCControl1.TabIndex = 5 ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(784, 520) Me.Controls.Add(Me.AxTOCControl1) Me.Controls.Add(Me.Label2) Me.Controls.Add(Me.Label1) Me.Controls.Add(Me.AxLicenseControl1) Me.Controls.Add(Me.AxPageLayoutControl1) Me.Controls.Add(Me.AxToolbarControl1) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog Me.Name = "Form1" Me.Text = "Add Map Surrounds" CType(Me.AxToolbarControl1, System.ComponentModel.ISupportInitialize).EndInit() CType(Me.AxPageLayoutControl1, System.ComponentModel.ISupportInitialize).EndInit() CType(Me.AxLicenseControl1, System.ComponentModel.ISupportInitialize).EndInit() CType(Me.AxTOCControl1, System.ComponentModel.ISupportInitialize).EndInit() Me.ResumeLayout(False) End Sub #End Region Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Set buddy control AxToolbarControl1.SetBuddyControl(AxPageLayoutControl1) AxTOCControl1.SetBuddyControl(AxPageLayoutControl1) 'Add ToolbarControl items AxToolbarControl1.AddItem("esriControls.ControlsOpenDocCommand", 0, -1, False, 0, esriCommandStyles.esriCommandStyleIconOnly) AxToolbarControl1.AddItem("esriControls.ControlsPageZoomInTool", 0, -1, True, 0, esriCommandStyles.esriCommandStyleIconOnly) AxToolbarControl1.AddItem("esriControls.ControlsPageZoomOutTool", 0, -1, False, 0, esriCommandStyles.esriCommandStyleIconOnly) AxToolbarControl1.AddItem("esriControls.ControlsPageZoomWholePageCommand", 0, -1, False, 0, esriCommandStyles.esriCommandStyleIconOnly) AxToolbarControl1.AddItem("esriControls.ControlsMapZoomInTool", 0, -1, True, 0, esriCommandStyles.esriCommandStyleIconOnly) AxToolbarControl1.AddItem("esriControls.ControlsMapZoomOutTool", 0, -1, False, 0, esriCommandStyles.esriCommandStyleIconOnly) AxToolbarControl1.AddItem("esriControls.ControlsMapPanTool", 0, -1, False, 0, esriCommandStyles.esriCommandStyleIconOnly) AxToolbarControl1.AddItem("esriControls.ControlsMapFullExtentCommand", 0, -1, False, 0, esriCommandStyles.esriCommandStyleIconOnly) AxToolbarControl1.AddItem("esriControls.ControlsSelectTool", 0, -1, True, 0, esriCommandStyles.esriCommandStyleIconOnly) 'Create a new ToolbarPalette Dim toolbarPalette As IToolbarPalette = New ToolbarPaletteClass toolbarPalette.Caption = "Map Surrounds" toolbarPalette.AddItem(New CreateNorthArrow, -1, -1) toolbarPalette.AddItem(New CreateScaleBar, -1, -1) toolbarPalette.AddItem(New CreateScaleText, -1, -1) 'Add the ToolbarPalette to the ToolbarControl AxToolbarControl1.AddItem(toolbarPalette, -1, -1, False, 0, esriCommandStyles.esriCommandStyleIconOnly) End Sub End Class