/// <summary> /// 打开数据库数据 /// </summary> private void OpenDBData() { try { OpenMap openMap = new OpenMap(); openMap.BindMap(); openMap.StartPosition = FormStartPosition.CenterParent; if (openMap.ShowDialog() == DialogResult.OK) { Map map = (Map)openMap.comboBoxMapList.SelectedItem; FormView frmTemp = new FormView(); //新建一个窗体对象,可根据需要新建自己设计的窗体 frmTemp.MdiParent = this; //设置窗口的MdiParent属性为当前主窗口,成为MDI子窗体 frmTemp.Text = map.MapName;; //设定MDI窗体的标题 frmTemp.Name = map.MapID; gMain.log.WriteLog("打开地图" + map.MapName + " :" + map.MapAddress); //frmTemp.SelectChanged += new System.EventHandler<SelectEventArgs>(this.FormView_ObjectSelectChanged); FormCount++; //FormCount是定义在主程序中的一个变量来记录产生的子窗口个数 m_CurrentView = frmTemp; frmTemp.SetContextMenu(int.Parse(map.MapID)); frmTemp.OpenDB(map); frmTemp.Show(); //把此MDI窗体显示出来 } } catch (Exception e) { gMain.log.WriteLog("打开数据库数据错误:" + e); } }
public void bShowMap_Click(object sender, EventArgs e) { OpenMap newMdiChildMap = new OpenMap(); try { project1 = Projects.project; pictureId1 = project1.ImageId; if (project1 != null && pictureId1 != null) { ((OpenMap)newMdiChildMap).pbMap.Image = System.Drawing.Image.FromFile(projectsKonstruktorEntities.Pictures1 .FirstOrDefault(q => q.PictureId == pictureId1).PictureName.ToString()); Byte[] byteBLOBData = (Byte[])projectsKonstruktorEntities.Pictures1 .FirstOrDefault(q => q.PictureId == pictureId1).PictureContent; MemoryStream ms = new MemoryStream(byteBLOBData); ms.Write(byteBLOBData, 0, byteBLOBData.Length); ms.Position = 0; ((OpenMap)newMdiChildMap).pbMap.Image = Image.FromStream(ms); newMdiChildMap.ShowDialog(); } } catch { Close(); } }
/// <summary> /// 打开数据库数据 /// </summary> private void OpenDBData() { try { OpenMap openMap = new OpenMap(); openMap.BindMap(); openMap.StartPosition = FormStartPosition.CenterParent; if (openMap.ShowDialog() == DialogResult.OK) { Map map = (Map)openMap.comboBoxMapList.SelectedItem; CreateView(); if (m_CurrentView != null) { m_CurrentView.Name = map.MapID; m_CurrentView.Text = map.MapName; m_CurrentView.SetContextMenu(int.Parse(map.MapID)); m_CurrentView.OpenDB(map); } } } catch (Exception e) { Log.WriteLog("打开数据库数据错误:" + e); } }