物探论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 569|回复: 0

c#中调用mapx5.0(一)_第三部分

[复制链接]
发表于 2013-3-15 18:13:58 | 显示全部楼层 |阅读模式
//
   // menuItem17
   //
   this.menuItem17.Index = 3;
   this.menuItem17.Text = "窗口";
   //
   // menuItem18
   //
   this.menuItem18.Index = 4;
   this.menuItem18.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
                        this.menuItem19});
   this.menuItem18.Text = "帮助";
   //
   // menuItem19
   //
   this.menuItem19.Index = 0;
   this.menuItem19.Text = "关于MapX";
   this.menuItem19.Click += new System.EventHandler(this.menuItem19_Click);
   //
   // comu
   //
   this.comu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
                     this.menuItem4,
                     this.menuItem5,
                     this.menuItem6,
                     this.menuItem7});
   //
   // menuItem4
   //
   this.menuItem4.Index = 0;
   this.menuItem4.Text = "普通";
   this.menuItem4.Click += new System.EventHandler(this.menuItem4_Click);
   //
   // menuItem5
   //
   this.menuItem5.Index = 1;
   this.menuItem5.Text = "矩形";
   this.menuItem5.Click += new System.EventHandler(this.menuItem5_Click);
   //
   // menuItem6
   //
   this.menuItem6.Index = 2;
   this.menuItem6.Text = "圆形";
   this.menuItem6.Click += new System.EventHandler(this.menuItem6_Click);
   //
   // menuItem7
   //
   this.menuItem7.Index = 3;
   this.menuItem7.Text = "多边形";
   this.menuItem7.Click += new System.EventHandler(this.menuItem7_Click);
   //
   // comu1
   //
   this.comu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
                      this.menuItem8,
                      this.menuItem9});
   //
   // menuItem8
   //
   this.menuItem8.Index = 0;
   this.menuItem8.Text = "添加符号";
   this.menuItem8.Click += new System.EventHandler(this.menuItem8_Click);
   //
   // menuItem9
   //
   this.menuItem9.Index = 1;
   this.menuItem9.Text = "添加";
   this.menuItem9.Click += new System.EventHandler(this.menuItem9_Click);
   //
   // splitter1
   //
   this.splitter1.Location = new System.Drawing.Point(0, 41);
   this.splitter1.Name = "splitter1";
   this.splitter1.Size = new System.Drawing.Size(3, 432);
   this.splitter1.TabIndex = 5;
   this.splitter1.TabStop = false;
   //
   // toolBar1
   //
   this.toolBar1.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
                      this.tbadddian,
                      this.tbaddxian,
                      this.tbaddquxian,
                      this.tbaddqumian,
                      this.tbline,
                      this.tbshezhi});
   this.toolBar1.Dock = System.Windows.Forms.DockStyle.None;
   this.toolBar1.DropDownArrows = true;
   this.toolBar1.Location = new System.Drawing.Point(0, 40);
   this.toolBar1.Name = "toolBar1";
   this.toolBar1.ShowToolTips = true;
   this.toolBar1.Size = new System.Drawing.Size(488, 28);
   this.toolBar1.TabIndex = 6;
   this.toolBar1.TextAlign = System.Windows.Forms.ToolBarTextAlign.Right;
   this.toolBar1.Visible = false;
   this.toolBar1.Wrappable = false;
   this.toolBar1.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.toolBar1_ButtonClick);
   //
   // tbadddian
   //
   this.tbadddian.Text = "点      ";
   this.tbadddian.Visible = false;
   //
   // tbaddxian
   //
   this.tbaddxian.Text = "线      ";
   this.tbaddxian.Visible = false;
   //
   // tbaddquxian
   //
   this.tbaddquxian.Text = "曲线       ";
   this.tbaddquxian.Visible = false;
   //
   // tbaddqumian
   //
   this.tbaddqumian.Text = "面      ";
   this.tbaddqumian.Visible = false;
   //
   // tbline
   //
   this.tbline.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
   //
   // tbshezhi
   //
   this.tbshezhi.Text = "设置         ";
   this.tbshezhi.Visible = false;
   //
   // menuItem33
   //
   this.menuItem33.Index = 7;
   this.menuItem33.Text = "打印设置";
   //
   // menuItem34
   //
   this.menuItem34.Index = 9;
   this.menuItem34.Text = "-";
   //
   // menuItem35
   //
   this.menuItem35.Index = 8;
   this.menuItem35.Text = "打印...";
   //
   // FrmMain
   //
   this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
   this.ClientSize = new System.Drawing.Size(776, 473);
   this.Controls.Add(this.toolBar1);
   this.Controls.Add(this.splitter1);
   this.Controls.Add(this.label1);
   this.Controls.Add(this.toolBar2);
   this.Controls.Add(this.axMap2);
   this.Controls.Add(this.axMap1);
   this.Menu = this.mainMenu1;
   this.Name = "FrmMain";
   this.Text = "FrmMain";
   this.Load += new System.EventHandler(this.Form1_Load);
   ((System.ComponentModel.ISupportInitialize)(this.axMap1)).EndInit();
   ((System.ComponentModel.ISupportInitialize)(this.axMap2)).EndInit();
   this.ResumeLayout(false);
  }
  #endregion
  #region 应用程序的主入口点
  /// <summary>
  /// 应用程序的主入口点。
  /// </summary>
  [STAThread]
  static void Main()
  {
   FrmMain FMain;
   Application.Run(FMain=new FrmMain());
  }
  #endregion
  //****************************************
  #region axMap1对象的属性操作,一般都在其他窗口里被使用
  /// <summary>
  /// 在这里适用属性主要是为了axMap1这个私有的对象能在其他窗体中获得一些需要的改变
  /// </summary>
  ///
  //属性1
     public MapXLib.Style  SyStyle                                         //属性操作,设置或取得符号的样式,在 Frmannotation 中使用了该属性,                  
  {
   set
   {
    axMap1.DefaultStyle=value;
   }
   get
   {
    return axMap1.DefaultStyle;
   }
  }
               //属性2
  public MapXLib.Style editStyle                                         //属性操作,设置或取得在编辑图层时,改变的点,线和曲面的样式 在Frmeditable
  {
   set                 //中使用了该属性,
   {
    axMap1.AutoRedraw=true;
    axMap1.Layers.InsertionLayer.Style=value;
   }
   get
   {
    axMap1.Layers.InsertionLayer.OverrideStyle=true;
    axMap1.AutoRedraw=false;
    return axMap1.Layers.InsertionLayer.Style;
   }
  }
  //属性3
  public MapXLib.Layers Layer                                          //属性操作,通过该属性,图层选择显示窗口(FrmViewLyr)可以操作axMap1的Layers属性,
  {                 //在FrmViewLyr_Load 时可以得到 Layers
   get
   {
    return axMap1.Layers;
   }
  }
  //属性4
  public string LyrName                                              //属性操作,通过该属性,得到图层选择显示窗口(FrmViewLyr)中cobLyr.text中的值
  {                  //来显示那个图层将被显示
   set
   {
    if(value=="All Layers")
     axMap1.CtlBounds=axMap1.Layers.Bounds;     //注意,这里使用CtlBounds属性(MapX的属性),而不是Bounds(.net本身的属性)在.net
    else
     axMap1.CtlBounds=axMap1.Layers[value].Bounds;   //环境下,有点改变,
   }
  }

        #endregion
  //***********************************
  #region 工具条,里面包含选择、拖动漫游、放大缩小等一些工具
  private void toolBar2_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
  {
   try
   {
    if(e.Button==tbfangda)
     axMap1.CurrentTool=MapXLib.ToolConstants.miZoomInTool;//1003
    if(e.Button==tbbianxiao)
     axMap1.CurrentTool=MapXLib.ToolConstants.miZoomOutTool;//缩小地图
    if(e.Button==tbmanyou)
     axMap1.CurrentTool=MapXLib.ToolConstants.miPanTool;//漫游地图
    if(e.Button==tbbiaozhu)        //标注地图
    {
     axMap1.CurrentTool=MapXLib.ToolConstants.miLabelTool;
     //Point p=new Point(20+55*5,20);
        //comu1.Show(toolBar2,p);
    }
    if(e.Button==tbtianjiafuhao)
     axMap1.CurrentTool=MapXLib.ToolConstants.miSymbolTool;
    if(e.Button==tbjuli)  
     axMap1.CurrentTool=( MapXLib.ToolConstants ) 10;
    if(e.Button==tbmianji)
     axMap1.CurrentTool=(MapXLib.ToolConstants ) 11;
    if(e.Button==tbshuaxin)
    {
                      //刷新地图,回到初始状态
     axMap1.ZoomTo(this.zoom,this.centerx,this.centery);       //恢复初始时的比例
     //axMap1.Annotations.RemoveAll();
     axMap1.Refresh();
    }
    if(e.Button==tbxuanze)
    {
     Point p=new Point(20,20);
     comu.Show(toolBar2,p);                                   //显示选择工具菜单,它允许选择矩形,圆形,多边形等  
    }

   }
   catch(Exception e1)
   {
    MessageBox.Show(e1.Message);
   }
  }
  #endregion

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|物探论坛 ( 鄂ICP备12002012号 微信号:iwutan )

GMT+8, 2024-5-11 16:59 , Processed in 0.072940 second(s), 15 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表