Beispiel #1
0
        private void Form1_Load(object sender, System.EventArgs e)
        {
            //Resize the controls so that they scale correctly at both 96 and 120 dpi
            AdjustBounds(this.axToolbarControl1);
            AdjustBounds(this.axLicenseControl1);
            AdjustBounds(this.axPageLayoutControl1);
            AdjustBounds(this.axSymbologyControl1);

            //Set the buddy control
            axToolbarControl1.SetBuddyControl(axPageLayoutControl1);

            //Add items to the ToolbarControl
            axToolbarControl1.AddItem("esriControls.ControlsOpenDocCommand", -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            axToolbarControl1.AddItem("esriControls.ControlsPageZoomInTool", -1, -1, true, 0, esriCommandStyles.esriCommandStyleIconOnly);
            axToolbarControl1.AddItem("esriControls.ControlsPageZoomOutTool", -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            axToolbarControl1.AddItem("esriControls.ControlsPageZoomWholePageCommand", -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            axToolbarControl1.AddItem("esriControls.ControlsSelectTool", -1, -1, true, 0, esriCommandStyles.esriCommandStyleIconOnly);
            axToolbarControl1.AddItem("esriControls.ControlsNewMarkerTool", -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            axToolbarControl1.AddItem("esriControls.ControlsNewLineTool", -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            axToolbarControl1.AddItem("esriControls.ControlsNewFreeHandTool", -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            axToolbarControl1.AddItem("esriControls.ControlsNewRectangleTool", -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            axToolbarControl1.AddItem("esriControls.ControlsNewPolygonTool", -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);

            //Get the ArcGIS install location by opening the subkey for reading
            //Load the ESRI.ServerStyle file into the SymbologyControl
            string installationFolder = ESRI.ArcGIS.RuntimeManager.ActiveRuntime.Path;

            axSymbologyControl1.LoadStyleFile(installationFolder + "\\Styles\\ESRI.ServerStyle");

            //Add style classes to the combo box
            ComboBox1.Items.Add("Default Marker Symbol");
            ComboBox1.Items.Add("Default Line Symbol");
            ComboBox1.Items.Add("Default Fill Symbol");
            ComboBox1.Items.Add("Default Text Symbol");
            ComboBox1.SelectedIndex = 0;

            //Update each style class. This forces item to be loaded into each style class.
            //When the contents of a server style file are loaded into the SymbologyControl
            //items are 'demand loaded'. This is done to increase performance and means
            //items are only loaded into a SymbologyStyleClass when it is the current StyleClass.
            axSymbologyControl1.GetStyleClass(esriSymbologyStyleClass.esriStyleClassMarkerSymbols).Update();
            axSymbologyControl1.GetStyleClass(esriSymbologyStyleClass.esriStyleClassLineSymbols).Update();
            axSymbologyControl1.GetStyleClass(esriSymbologyStyleClass.esriStyleClassFillSymbols).Update();
            axSymbologyControl1.GetStyleClass(esriSymbologyStyleClass.esriStyleClassTextSymbols).Update();

            //Get the CommandsEnvironment singleton
            m_graphicProperties = new CommandsEnvironmentClass();

            //Create a new ServerStyleGalleryItem and set its name
            IStyleGalleryItem styleGalleryItem = new ServerStyleGalleryItemClass();

            styleGalleryItem.Name = "myStyle";

            ISymbologyStyleClass styleClass;

            //Get the marker symbol style class
            styleClass = axSymbologyControl1.GetStyleClass(esriSymbologyStyleClass.esriStyleClassMarkerSymbols);
            //Set the commands environment marker symbol into the item
            styleGalleryItem.Item = m_graphicProperties.MarkerSymbol;
            //Add the item to the style class
            styleClass.AddItem(styleGalleryItem, 0);

            //Get the line symbol style class
            styleClass = axSymbologyControl1.GetStyleClass(esriSymbologyStyleClass.esriStyleClassLineSymbols);
            //Set the commands environment line symbol into the item
            styleGalleryItem.Item = m_graphicProperties.LineSymbol;
            //Add the item to the style class
            styleClass.AddItem(styleGalleryItem, 0);

            //Get the fill symbol style class
            styleClass = axSymbologyControl1.GetStyleClass(esriSymbologyStyleClass.esriStyleClassFillSymbols);
            //Set the commands environment fill symbol into the item
            styleGalleryItem.Item = m_graphicProperties.FillSymbol;
            //Add the item to the style class
            styleClass.AddItem(styleGalleryItem, 0);

            //Get the text symbol style class
            styleClass = axSymbologyControl1.GetStyleClass(esriSymbologyStyleClass.esriStyleClassTextSymbols);
            //Set the commands environment text symbol into the item
            styleGalleryItem.Item = m_graphicProperties.TextSymbol;
            //Add the item to the style class
            styleClass.AddItem(styleGalleryItem, 0);
        }
		private void Form1_Load(object sender, System.EventArgs e)
		{
			//Resize the controls so that they scale correctly at both 96 and 120 dpi
            AdjustBounds(this.axToolbarControl1);
            AdjustBounds(this.axLicenseControl1);
            AdjustBounds(this.axPageLayoutControl1);
            AdjustBounds(this.axSymbologyControl1);
             
            //Set the buddy control
			axToolbarControl1.SetBuddyControl(axPageLayoutControl1);

			//Add items to the ToolbarControl
			axToolbarControl1.AddItem("esriControls.ControlsOpenDocCommand", -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
			axToolbarControl1.AddItem("esriControls.ControlsPageZoomInTool", -1, -1, true, 0, esriCommandStyles.esriCommandStyleIconOnly);
			axToolbarControl1.AddItem("esriControls.ControlsPageZoomOutTool", -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
			axToolbarControl1.AddItem("esriControls.ControlsPageZoomWholePageCommand", -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
			axToolbarControl1.AddItem("esriControls.ControlsSelectTool", -1, -1, true, 0, esriCommandStyles.esriCommandStyleIconOnly);
			axToolbarControl1.AddItem("esriControls.ControlsNewMarkerTool", -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
			axToolbarControl1.AddItem("esriControls.ControlsNewLineTool", -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
			axToolbarControl1.AddItem("esriControls.ControlsNewFreeHandTool", -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
			axToolbarControl1.AddItem("esriControls.ControlsNewRectangleTool", -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
			axToolbarControl1.AddItem("esriControls.ControlsNewPolygonTool", -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);

			//Get the ArcGIS install location by opening the subkey for reading			
			//Load the ESRI.ServerStyle file into the SymbologyControl
            string installationFolder = ESRI.ArcGIS.RuntimeManager.ActiveRuntime.Path;
            axSymbologyControl1.LoadStyleFile(installationFolder + "\\Styles\\ESRI.ServerStyle");

			//Add style classes to the combo box
			ComboBox1.Items.Add("Default Marker Symbol");
			ComboBox1.Items.Add("Default Line Symbol");
			ComboBox1.Items.Add("Default Fill Symbol");
			ComboBox1.Items.Add("Default Text Symbol");
			ComboBox1.SelectedIndex = 0;

			//Update each style class. This forces item to be loaded into each style class.
			//When the contents of a server style file are loaded into the SymbologyControl 
			//items are 'demand loaded'. This is done to increase performance and means 
			//items are only loaded into a SymbologyStyleClass when it is the current StyleClass.
			axSymbologyControl1.GetStyleClass(esriSymbologyStyleClass.esriStyleClassMarkerSymbols).Update();
			axSymbologyControl1.GetStyleClass(esriSymbologyStyleClass.esriStyleClassLineSymbols).Update();
			axSymbologyControl1.GetStyleClass(esriSymbologyStyleClass.esriStyleClassFillSymbols).Update();
			axSymbologyControl1.GetStyleClass(esriSymbologyStyleClass.esriStyleClassTextSymbols).Update();

			//Get the CommandsEnvironment singleton
			m_graphicProperties = new CommandsEnvironmentClass();

			//Create a new ServerStyleGalleryItem and set its name
			IStyleGalleryItem styleGalleryItem = new ServerStyleGalleryItemClass();
			styleGalleryItem.Name = "myStyle";

			ISymbologyStyleClass styleClass;

			//Get the marker symbol style class
			styleClass = axSymbologyControl1.GetStyleClass(esriSymbologyStyleClass.esriStyleClassMarkerSymbols);
			//Set the commands environment marker symbol into the item
			styleGalleryItem.Item = m_graphicProperties.MarkerSymbol;
			//Add the item to the style class
			styleClass.AddItem(styleGalleryItem, 0);

			//Get the line symbol style class
			styleClass = axSymbologyControl1.GetStyleClass(esriSymbologyStyleClass.esriStyleClassLineSymbols);
			//Set the commands environment line symbol into the item
			styleGalleryItem.Item = m_graphicProperties.LineSymbol;
			//Add the item to the style class
			styleClass.AddItem(styleGalleryItem, 0);

			//Get the fill symbol style class
			styleClass = axSymbologyControl1.GetStyleClass(esriSymbologyStyleClass.esriStyleClassFillSymbols);
			//Set the commands environment fill symbol into the item
			styleGalleryItem.Item = m_graphicProperties.FillSymbol;
			//Add the item to the style class
			styleClass.AddItem(styleGalleryItem, 0);

			//Get the text symbol style class
			styleClass = axSymbologyControl1.GetStyleClass(esriSymbologyStyleClass.esriStyleClassTextSymbols);
			//Set the commands environment text symbol into the item
			styleGalleryItem.Item = m_graphicProperties.TextSymbol;
			//Add the item to the style class
			styleClass.AddItem(styleGalleryItem, 0);

		}