private void tsmiOpen_Click(object sender, EventArgs e)
        {
            frmFileDialog openfileDlg = new frmFileDialog(false);

            //openfileDlg.Multiselect = false;
            //openfileDlg.InitialDirectory = Application.StartupPath + "\\MapGis\\MapConfigFiles";
            //openfileDlg.Filter = "三恒科技图形系统文件|*.shz";
            if (openfileDlg.ShowDialog() == DialogResult.OK)
            {
                pnlInOut.Visible = true;
                if (!IsOut)
                {
                    this.picInOut_Click(this, new EventArgs());
                }
                if (gcfb.ExitsFile(openfileDlg.SafeFileName))
                {
                    DataTable   bufferdt    = gcfb.GetXmlAndMapByFileName(openfileDlg.SafeFileName);
                    byte[]      xmlbytes    = (byte[])bufferdt.Rows[0][0];
                    byte[]      mapbytes    = (byte[])bufferdt.Rows[0][1];
                    FileChanger filechanger = new FileChanger();
                    ConfigXml = filechanger.BytesToXml(xmlbytes);
                    LoadMapConfig(filechanger.BytesToXml(xmlbytes), mapbytes);
                    this.isSaveed = false;
                }
                else
                {
                    MessageBox.Show("您所选择的文件不存在!", "提示", MessageBoxButtons.OK);
                }
            }
        }
 private void lnkSave_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     if (isSaveed == false)
     {
         frmFileDialog f = new frmFileDialog();
         //f.InitialDirectory = Application.StartupPath + "\\MapGis\\MapConfigFiles";
         //f.DefaultExt = "shz";
         //f.Filter = "三恒科技图形系统配置文件|*.shz";
         if (f.ShowDialog() == DialogResult.OK)
         {
             //ConfigXml.Save(f.FileName);
             string  filename = f.SafeFileName;
             byte[]  xmlbytes = new FileChanger().XmlToBytes(ConfigXml);
             XmlNode MapNode  = ConfigXml.SelectSingleNode("//Map");
             if (!System.IO.File.Exists(Application.StartupPath + MapNode.InnerText))
             {
                 MessageBox.Show("底图尚未选择或您选择的底图不正确!", "提示", MessageBoxButtons.OK);
                 return;
             }
             byte[] imgbytes = new FileChanger().ImageToBytes(Application.StartupPath + MapNode.InnerText);
             if (gcfb.ExitsFile(filename))
             {
                 gcfb.UpdateFile(filename, xmlbytes, imgbytes);
             }
             else
             {
                 gcfb.AddFile(filename, xmlbytes, imgbytes);
             }
             this.isSaveed = true;
         }
     }
 }
Example #3
0
 private void tsmiOpen_Click(object sender, EventArgs e)
 {
     frmFileDialog openfileDlg = new frmFileDialog(false);
     //openfileDlg.Multiselect = false;
     //openfileDlg.InitialDirectory = Application.StartupPath + "\\MapGis\\MapConfigFiles";
     //openfileDlg.Filter = "三恒科技图形系统文件|*.shz";
     if (openfileDlg.ShowDialog() == DialogResult.OK)
     {
         pnlInOut.Visible = true;
         if (!IsOut)
         {
             this.picInOut_Click(this, new EventArgs());
         }
         if (gcfb.ExitsFile(openfileDlg.SafeFileName))
         {
             DataTable bufferdt = gcfb.GetXmlAndMapByFileName(openfileDlg.SafeFileName);
             byte[] xmlbytes = (byte[])bufferdt.Rows[0][0];
             byte[] mapbytes = (byte[])bufferdt.Rows[0][1];
             FileChanger filechanger = new FileChanger();
             ConfigXml = filechanger.BytesToXml(xmlbytes);
             LoadMapConfig(filechanger.BytesToXml(xmlbytes), mapbytes);
             this.isSaveed = false;
         }
         else
         {
             MessageBox.Show("您所选择的文件不存在!", "提示", MessageBoxButtons.OK);
         }
     }
 }
 private void tsmiFileOpen_Click(object sender, EventArgs e)
 {
     frmFileDialog openfileDlg = new frmFileDialog(false);
     if (openfileDlg.ShowDialog() == DialogResult.OK)
     {
         this.MapGis.UseDiv = true;
         this.MapGis.ReSet();
         XmlDocument xmldoc = new XmlDocument();
         DataTable bufferdt = gcfb.GetXmlAndMapByFileName(openfileDlg.SafeFileName);
         byte[] xmlbytes = (byte[])bufferdt.Rows[0][0];
         byte[] mapbytes = (byte[])bufferdt.Rows[0][1];
         FileChanger filechanger = new FileChanger();
         xmldoc = filechanger.BytesToXml(xmlbytes);
         XmlNode node = xmldoc.SelectSingleNode("//Map");
         if (node != null)
         {
             try
             {
                 CreateWmf(mapbytes, Application.StartupPath + node.InnerText);
             }
             catch (Exception ex)
             {
                 MessageBox.Show("读取图形系统配置文件发生错误,可能配置文件未完成或已损坏!", "提示", MessageBoxButtons.OK);
             }
         }
         else
         {
             MessageBox.Show("读取图形系统配置文件发生错误,可能配置文件未完成或已损坏!", "提示", MessageBoxButtons.OK);
         }
         if (!new MapXml().LoadAllMapConfig(xmldoc, MapGis))
         {
             pnlInOut.Visible = false;
             SetMenuEnabel(false);
             MapGis.Refresh();
             return;
         }
     }
     else
     {
         return;
     }
     //this.MapGis.StationClick += new ZzhaControlLibrary.ZzhaMapGis.ClickStation(MapGis_StationClick);
     StartTimer();
     IsOut = true;
     LoadRealTimeInfo();
     IsOut = false;
     pnlInOut.Visible = true;
     SetMenuEnabel(true);
 }
Example #5
0
 private void lnkSave_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     if (isSaveed == false)
     {
         frmFileDialog f = new frmFileDialog();
         //f.InitialDirectory = Application.StartupPath + "\\MapGis\\MapConfigFiles";
         //f.DefaultExt = "shz";
         //f.Filter = "三恒科技图形系统配置文件|*.shz";
         if (f.ShowDialog() == DialogResult.OK)
         {
             //ConfigXml.Save(f.FileName);
             string filename = f.SafeFileName;
             byte[] xmlbytes = new FileChanger().XmlToBytes(ConfigXml);
             XmlNode MapNode = ConfigXml.SelectSingleNode("//Map");
             if (!System.IO.File.Exists(Application.StartupPath + MapNode.InnerText))
             {
                 MessageBox.Show("底图尚未选择或您选择的底图不正确!", "提示", MessageBoxButtons.OK);
                 return;
             }
             byte[] imgbytes = new FileChanger().ImageToBytes(Application.StartupPath + MapNode.InnerText);
             if(gcfb.ExitsFile(filename))
                 gcfb.UpdateFile(filename, xmlbytes, imgbytes);
             else
                 gcfb.AddFile(filename, xmlbytes, imgbytes);
             this.isSaveed = true;
         }
     }
 }