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; } } }
private bool CanShowMap() { try { //this.MapGis.MapFilePath = Application.StartupPath + MapFilePath; try { DataTable dt = dpicbll.GetBackPicByFileID(FileID); byte[] buffer = (byte[])dt.Rows[0][0]; Graphics.Config.FileChanger fc = new KJ128NMainRun.Graphics.Config.FileChanger(); if (!System.IO.Directory.Exists(Application.StartupPath + "\\MapGis\\DMap")) { System.IO.Directory.CreateDirectory(Application.StartupPath + "\\MapGis\\DMap"); } fc.CreateFile(Application.StartupPath + "\\MapGis\\DMap\\" + dt.Rows[0][1].ToString(), buffer); this.MapGis.MapFilePath = Application.StartupPath + "\\MapGis\\DMap\\" + dt.Rows[0][1].ToString(); System.IO.File.Delete(Application.StartupPath + "\\MapGis\\DMap\\" + dt.Rows[0][1].ToString()); } catch (Exception ex) { MessageBox.Show("无法识别的图片!", "提示", MessageBoxButtons.OK); return(false); } try { if (Convert.ToInt32(ntbMin.Text) > Convert.ToInt32(ntbMax.Text)) { throw new Exception(); } this.MapGis.MinWidth = Convert.ToInt32(ntbMin.Text); this.MapGis.MaxWidth = Convert.ToInt32(ntbMax.Text); } catch (Exception ex) { MessageBox.Show("图层显示范围没有配置或配置不正确,请检查!", "提示", MessageBoxButtons.OK); return(false); } } catch (Exception ex) { MessageBox.Show("存取文件异常!", "提示", MessageBoxButtons.OK); return(false); } AddSelectedStations(); //LoadStatic(); HasMonied = true; MapGis.FlashAll(); pnl2.Visible = true; pnl3.Visible = true; return(true); }
private void tsmiFileOpen_Click(object sender, EventArgs e) { frmDFileDialog openfileDlg = new frmDFileDialog(false); if (openfileDlg.ShowDialog() == DialogResult.OK) { this.MapGis.UseDiv = true; this.MapGis.ReSet(); XmlDocument xmldoc = new XmlDocument(); DataTable bufferdt = dpicbll.GetXmlByFileName(openfileDlg.SafeFileName); byte[] xmlbytes = (byte[])bufferdt.Rows[0][0]; FileChanger filechanger = new FileChanger(); xmldoc = filechanger.BytesToXml(xmlbytes); XmlNode node = xmldoc.SelectSingleNode("//Map"); this.FileID = node.InnerText; //if (node != null) //{ // try // { // CreateWmf(mapbytes, Application.StartupPath + node.InnerText); // } // catch (Exception ex) // { // MessageBox.Show("读取图形系统配置文件发生错误,可能配置文件未完成或已损坏!", "提示", MessageBoxButtons.OK); // } //} //else //{ // MessageBox.Show("读取图形系统配置文件发生错误,可能配置文件未完成或已损坏!", "提示", MessageBoxButtons.OK); //} if (!new KJ128NMainRun.Graphics.DPic.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); }
private void OpenFile(string filename,DataGridView dgv) { try { //frmDFileDialog openfileDlg = new frmDFileDialog(false); //if (openfileDlg.ShowDialog() == DialogResult.OK) //{ this.MapGis.UseDiv = true; this.MapGis.ReSet(); XmlDocument xmldoc = new XmlDocument(); DataTable bufferdt = dpicbll.GetXmlByFileName(filename); byte[] xmlbytes = (byte[])bufferdt.Rows[0][0]; FileChanger filechanger = new FileChanger(); xmldoc = filechanger.BytesToXml(xmlbytes); XmlNode node = xmldoc.SelectSingleNode("//Map"); this.FileID = node.InnerText; XmlNode divsnode = xmldoc.SelectSingleNode("//Divs"); ReFlashDivDt(divsnode); dgv.DataSource = DivDt; for (int i = 0; i < dgv.Rows.Count; i++) { ((DataGridViewCheckBoxCell)dgv.Rows[i].Cells[0]).Value = ((DataGridViewCheckBoxCell)dgv.Rows[i].Cells[0]).TrueValue; } //if (node != null) //{ // try // { // CreateWmf(mapbytes, Application.StartupPath + node.InnerText); // } // catch (Exception ex) // { // MessageBox.Show("读取图形系统配置文件发生错误,可能配置文件未完成或已损坏!", "提示", MessageBoxButtons.OK); // } //} //else //{ // MessageBox.Show("读取图形系统配置文件发生错误,可能配置文件未完成或已损坏!", "提示", MessageBoxButtons.OK); //} if (!new KJ128NMainRun.Graphics.DPic.MapXml().LoadAllMapConfig(xmldoc, MapGis)) { pnlInOut.Visible = false; SetMenuEnabel(false); MapGis.Refresh(); return; } //} //else //{ // return; //} //this.MapGis.StationClick += new ZzhaControlLibrary.ZzhaMapGis.ClickStation(MapGis_StationClick); HidePnls(); StartTimer(); IsOut = true; LoadRealTimeInfo(); IsOut = false; pnlInOut.Visible = true; SetMenuEnabel(true); } catch (Exception ex) { MessageBox.Show("读取图形发生错误,可能配置未完成或已损坏!", "提示", MessageBoxButtons.OK); return; } }
private void OpenFile(string filename,DataGridView dgv) { //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(filename); byte[] xmlbytes = (byte[])bufferdt.Rows[0][0]; byte[] mapbytes = (byte[])bufferdt.Rows[0][1]; FileChanger filechanger = new FileChanger(); xmldoc = filechanger.BytesToXml(xmlbytes); CreateDgv(dgv, xmldoc); 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); }
private void ShowMap() { try { //this.MapGis.MapFilePath = Application.StartupPath + MapFilePath; try { DataTable dt = dpicbll.GetBackPicByFileID(FileID); byte[] buffer = (byte[])dt.Rows[0][0]; Graphics.Config.FileChanger fc = new KJ128NMainRun.Graphics.Config.FileChanger(); if (!System.IO.Directory.Exists(Application.StartupPath + "\\MapGis\\DMap")) { System.IO.Directory.CreateDirectory(Application.StartupPath + "\\MapGis\\DMap"); } fc.CreateFile(Application.StartupPath + "\\MapGis\\DMap\\" + dt.Rows[0][1].ToString(), buffer); this.MapGis.MapFilePath = Application.StartupPath + "\\MapGis\\DMap\\" + dt.Rows[0][1].ToString(); System.IO.File.Delete(Application.StartupPath + "\\MapGis\\DMap\\" + dt.Rows[0][1].ToString()); } catch (Exception ex) { MessageBox.Show("无法识别的图片!", "提示", MessageBoxButtons.OK); return; } if (Convert.ToInt32(ntbMin.Text) > Convert.ToInt32(ntbMax.Text)) throw new Exception(); this.MapGis.MinWidth = Convert.ToInt32(ntbMin.Text); this.MapGis.MaxWidth = Convert.ToInt32(ntbMax.Text); } catch (Exception ex) { //MessageBox.Show("图层显示范围没有配置或配置不正确,请检查!", "提示", MessageBoxButtons.OK); //return; } MapGis.ClearAllStation(); MapGis.ClearAllStatic(); AddSelectedStations(); LoadStatic(); HasMonied = true; MapGis.FlashAll(); pnl2.Visible = true; pnl3.Visible = true; }
private void tsmiClose_Click(object sender, EventArgs e) { if (!isSaveed) { DialogResult result = MessageBox.Show("是否需要保存该图形系统文件?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { try { if (isSaveed == false) { //if (MapConfiged) //{ // frmDFileDialog f = new frmDFileDialog(); // //f.InitialDirectory = Application.StartupPath + "\\MapGis\\MapConfigFiles"; // //f.DefaultExt = "shz"; // //f.Filter = "三恒科技图形系统配置文件|*.shz"; // if (f.ShowDialog() == DialogResult.OK) // { //ConfigXml.Save(f.FileName); string filename = NowFileName; byte[] xmlbytes = new FileChanger().XmlToBytes(ConfigXml); if (dpicbll.ExitsFileName(filename)) dpicbll.UpdateFile(filename, xmlbytes, FileID); else dpicbll.AddFile(filename, xmlbytes, FileID); this.isSaveed = true; MessageBox.Show("保存成功", "提示", MessageBoxButtons.OK); // } //} //else //{ // MessageBox.Show("底图尚未配置!", "提示", MessageBoxButtons.OK); //} } } catch (Exception ex) { MessageBox.Show("保存失败", "提示", MessageBoxButtons.OK); } } } isSaveed = true; MapGis.ReSet(); MapGis.Refresh(); InitConfigXml(); LastSelectNode = null; MapConfiged = false; this.picMap.Image = null; this.ntbMax.Text = string.Empty; this.ntbMin.Text = string.Empty; this.trvDiv.Nodes.Clear(); if(IsOut) { this.picInOut_Click(this, new EventArgs()); } //this.pnlInOut.Visible = false; }
private void FrmCreateConfig_FormClosing(object sender, FormClosingEventArgs e) { if (!isSaveed) { DialogResult result = MessageBox.Show("是否需要保存该图形系统文件?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { //this.lnkSave_LinkClicked(this, new LinkLabelLinkClickedEventArgs(lnkSave.Links[0])); try { if (isSaveed == false) { //if (MapConfiged) //{ // frmDFileDialog f = new frmDFileDialog(); // //f.InitialDirectory = Application.StartupPath + "\\MapGis\\MapConfigFiles"; // //f.DefaultExt = "shz"; // //f.Filter = "三恒科技图形系统配置文件|*.shz"; // if (f.ShowDialog() == DialogResult.OK) // { //ConfigXml.Save(f.FileName); string filename = NowFileName; byte[] xmlbytes = new FileChanger().XmlToBytes(ConfigXml); if (dpicbll.ExitsFileName(filename)) dpicbll.UpdateFile(filename, xmlbytes, FileID); else dpicbll.AddFile(filename, xmlbytes, FileID); this.isSaveed = true; MessageBox.Show("保存成功", "提示", MessageBoxButtons.OK); // } //} //else //{ // MessageBox.Show("底图尚未配置!", "提示", MessageBoxButtons.OK); //} } } catch (Exception ex) { MessageBox.Show("保存失败", "提示", MessageBoxButtons.OK); } } } ConfigXmlWiter.Write("Picture.xml"); }
private void tsmiOpen_Click(object sender, EventArgs e) { frmDFileDialog openfileDlg = new frmDFileDialog(false); //openfileDlg.Multiselect = false; //openfileDlg.InitialDirectory = Application.StartupPath + "\\MapGis\\MapConfigFiles"; //openfileDlg.Filter = "三恒科技图形系统文件|*.shz"; if (openfileDlg.ShowDialog() == DialogResult.OK) { //pnlInOut.Visible = false; if (!IsOut) { this.picInOut_Click(this, new EventArgs()); } if (dpicbll.ExitsFileName(openfileDlg.SafeFileName)) { DataTable bufferdt = dpicbll.GetXmlByFileName(openfileDlg.SafeFileName); byte[] xmlbytes = (byte[])bufferdt.Rows[0][0]; FileChanger filechanger = new FileChanger(); ConfigXml = filechanger.BytesToXml(xmlbytes); LoadMapConfig(filechanger.BytesToXml(xmlbytes)); this.isSaveed = false; } else { MessageBox.Show("您所选择的文件不存在!", "提示", MessageBoxButtons.OK); } } }
private void lnkSave_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { if (isSaveed == false) { if (MapConfiged) { frmDFileDialog f = new frmDFileDialog(); //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); if (dpicbll.ExitsFileName(filename)) dpicbll.UpdateFile(filename, xmlbytes, FileID); else dpicbll.AddFile(filename, xmlbytes, FileID); this.isSaveed = true; } } else { MessageBox.Show("底图尚未配置!", "提示", MessageBoxButtons.OK); } } }
private void OpenFile(string filename, DataGridView dgv) { //frmFileDialog openfileDlg = new frmFileDialog(false); //if (openfileDlg.ShowDialog() == DialogResult.OK) //{ //this.MapGis.UseDiv = true; //this.MapGis.ReSet(); //XmlDocument xmldoc = new XmlDocument(); //DataTable bufferdt = dpicbll.GetXmlByFileName(filename); //if (bufferdt.Rows.Count > 0) //{ // byte[] xmlbytes = (byte[])bufferdt.Rows[0][0]; // FileChanger filechanger = new FileChanger(); // xmldoc = filechanger.BytesToXml(xmlbytes); // XmlNode node = xmldoc.SelectSingleNode("//Map"); // this.FileID = node.InnerText; // //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 = true; // //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); if (dpicbll.ExitsFileName(filename)) { DataTable bufferdt = dpicbll.GetXmlByFileName(filename); byte[] xmlbytes = (byte[])bufferdt.Rows[0][0]; FileChanger filechanger = new FileChanger(); ConfigXml = filechanger.BytesToXml(xmlbytes); LoadMapConfig(filechanger.BytesToXml(xmlbytes)); //this.isSaveed = false; } else { MessageBox.Show("打开文件时发生错误...", "提示", MessageBoxButtons.OK); } btnMoni_Click(this, new EventArgs()); for (int i = 0; i < dgv.Rows.Count; i++) { if (((DataGridViewCheckBoxCell)dgv.Rows[i].Cells[0]).Value == ((DataGridViewCheckBoxCell)dgv.Rows[i].Cells[0]).FalseValue) { MapGis.FilterDivList.Add(dgv.Rows[i].Cells[1].Value.ToString()); } if (((DataGridViewCheckBoxCell)dgv.Rows[i].Cells[0]).Value == ((DataGridViewCheckBoxCell)dgv.Rows[i].Cells[0]).TrueValue) { MapGis.FilterDivList.Remove(dgv.Rows[i].Cells[1].Value.ToString()); } } MapGis.Refresh(); }
private void btnSaveConfig_Click(object sender, EventArgs e) { try { if (isSaveed == false) { //if (MapConfiged) //{ // frmDFileDialog f = new frmDFileDialog(); // //f.InitialDirectory = Application.StartupPath + "\\MapGis\\MapConfigFiles"; // //f.DefaultExt = "shz"; // //f.Filter = "三恒科技图形系统配置文件|*.shz"; // if (f.ShowDialog() == DialogResult.OK) // { //ConfigXml.Save(f.FileName); string filename = NowBtn.Text; byte[] xmlbytes = new FileChanger().XmlToBytes(ConfigXml); if (dpicbll.ExitsFileName(filename)) dpicbll.UpdateFile(filename, xmlbytes, FileID); else dpicbll.AddFile(filename, xmlbytes, FileID); this.isSaveed = true; MessageBox.Show("保存成功", "提示", MessageBoxButtons.OK); // } //} //else //{ // MessageBox.Show("底图尚未配置!", "提示", MessageBoxButtons.OK); //} } } catch (Exception ex) { MessageBox.Show("保存失败", "提示", MessageBoxButtons.OK); } }
private void OpenFile(string filename, DataGridView dgv) { if (dpicbll.ExitsFileName(filename)) { DataTable bufferdt = dpicbll.GetXmlByFileName(filename); byte[] xmlbytes = (byte[])bufferdt.Rows[0][0]; FileChanger filechanger = new FileChanger(); ConfigXml = filechanger.BytesToXml(xmlbytes); LoadMapConfig(filechanger.BytesToXml(xmlbytes)); } else { MessageBox.Show("打开文件时发生错误...", "提示", MessageBoxButtons.OK); } btnMoni_Click(this, new EventArgs()); for (int i = 0; i < dgv.Rows.Count; i++) { if (((DataGridViewCheckBoxCell)dgv.Rows[i].Cells[0]).Value == ((DataGridViewCheckBoxCell)dgv.Rows[i].Cells[0]).FalseValue) { MapGis.FilterDivList.Add(dgv.Rows[i].Cells[1].Value.ToString()); } if (((DataGridViewCheckBoxCell)dgv.Rows[i].Cells[0]).Value == ((DataGridViewCheckBoxCell)dgv.Rows[i].Cells[0]).TrueValue) { MapGis.FilterDivList.Remove(dgv.Rows[i].Cells[1].Value.ToString()); } } MapGis.Refresh(); }
public void btnSaveConfig_Click(object sender, EventArgs e) { if (trvDiv.Nodes.Count < 1 & f != null) { tsmiAdd_Click(sender, e); //tsmEdit_Click(sender, e); InitializeDDiv(); f.btnSelectAll_Click(sender, e); f.btnSave_Click(sender, e); f.btnClose_Click(sender, e); } try { if (isSaveed == false) { string filename = string.Empty; if (NowBtn != null) { filename = NowBtn.Text; } else { filename = FileName; } byte[] xmlbytes = new FileChanger().XmlToBytes(ConfigXml); if (dpicbll.ExitsFileName(filename)) dpicbll.UpdateFile(filename, xmlbytes, FileID); else dpicbll.AddFile(filename, xmlbytes, FileID); this.isSaveed = true; //Czlt-2011-12-10 修改时间 dpicbll.UpdateTime(); MessageBox.Show("保存成功", "提示", MessageBoxButtons.OK); } } catch (Exception ex) { 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; } } }