private object OpenEdieView() { try { Main.Interface.ComeBaseModule.UnManagerObjectPolling.AddObject("controlcontent", this, true); FrmThempEditView editview = new FrmThempEditView(this); editview.FormClosed += new System.Windows.Forms.FormClosedEventHandler(editview_FormClosed); editview.ReadSourceEvent += new FrmThempEditView.ReadSourceHander(editview_ReadSourceEvent); ThempEditArgs <WeifenLuo.WinFormsUI.Docking.DockContent> args = new ThempEditArgs <WeifenLuo.WinFormsUI.Docking.DockContent>(editview); return(args); } catch (Main.Interface.ComeBaseModule.ComeRestException err) { base.OnComeExceptionEvent(err);//统一记录构件内部处理错误 return(null); } }
void Tools_filelist_SelectedIndexChanged(object sender, EventArgs e) { ThempEditArgs <string> args = new ThempEditArgs <string>(coll[Tools_filelist.SelectedIndex].filepath); ReadSourceEvent(args);//让主程序看见打开的文件目录 //读取模板文件进行编辑 string filename = Tools_filelist.SelectedItem.ToString() + ".vm"; filepath = Path.Combine(System.Configuration.ConfigurationManager.AppSettings["CodeThempPath"] + "\\", filename); this.toolStripStatusLabel2.Text = filepath; //显示模板的读取路径 using (FileStream filestream = File.Open(filepath, FileMode.Open, FileAccess.Read)) //单独打开,不影响其他程序的操作 { byte[] filebyte = new byte[filestream.Length]; filestream.Read(filebyte, 0, filebyte.Length); StringBuilder code = new StringBuilder(Encoding.UTF8.GetString(filebyte)); this.ucCodeView1.CodeText = code.ToString(); } }
void editview_ReadSourceEvent(ThempEditArgs <string> source) { _openeditcondeevent(this, source); }