private void buttonWSInvoke_Click(object sender, EventArgs e) { TabControl tabCtrl = this.Parent.Parent as TabControl; if (tabCtrl == null) { return; } foreach (TabPage tabPage in tabCtrl.TabPages) { foreach (Control ctl in tabPage.Controls) { IConfigControl cCtrl = ctl as IConfigControl; if (cCtrl != null) { cCtrl.SaveConfig(); continue; } IConfigUI aCtrl = ctl as IConfigUI; if (aCtrl != null) { aCtrl.SaveConfig(); continue; } } } }
public bool LoadConfig() { string filename = Application.StartupPath + "\\OutboundDBInstall.exe"; if (File.Exists(filename)) { Assembly asm = AssemblyHelper.LoadAssembly(filename); if (asm == null) { MessageBox.Show(this, AssemblyHelper.LastError.ToString(), "Load assembly error."); return(true); } Type type = null; Type[] tlist = asm.GetTypes(); if (tlist != null) { foreach (Type t in tlist) { Type it = t.GetInterface("IConfigUI"); if (it != null) { type = t; break; } } } if (type != null) { try { ui = Activator.CreateInstance(type) as IConfigUI; } catch (Exception err) { MessageBox.Show(this, err.ToString(), "Create instance error."); return(true); } } try { if (ui != null) { Control ctrl = ui.GetControl(); ctrl.Dock = DockStyle.Fill; this.Controls.Add(ctrl); ui.LoadConfig(); } } catch (Exception e) { MessageBox.Show(this, e.ToString(), "IConfigUI GetControl error."); return(true); } } return(true); }
private void LoadMainConfigTabPage() { _entityConfig = _entityAgent.EntityConfigInstance; IConfigUI[] uilist = _entityConfig.GetIConfigUI(); if (uilist == null || uilist.Length < 1) { return; } _configUI = uilist[0]; Control ctl = _configUI.GetControl(); EntityLoader.PrepareControl(ctl, this); this.panelMain.Controls.Add(ctl); this.tabPageMain.Text = _configUI.Title; }
private void LoadAdapterConfig(Type adapterType) { IAdapterConfig adapter = AssemblyHelper.CreateAdapter <IAdapterConfig>(adapterType); if (adapter == null) { MessageBox.Show("Cannot create instance of type " + adapterType.ToString() + "\r\n\r\n" + AssemblyHelper.LastErrorInfor); return; } IConfigUI[] uilist = adapter.GetConfigUI(); if (uilist != null && uilist.Length > 0) { _config = uilist[0]; } if (_config == null) { MessageBox.Show("Cannot get config implementation from adapter " + adapterType.ToString()); return; } Control ctrl = _config.GetControl(); if (ctrl == null) { MessageBox.Show("Cannot get config GUI from adapter " + adapterType.ToString()); return; } AssemblyHelper.PrepareControl(ctrl, tabPage2); tabPage2.Controls.Add(ctrl); //this.Text = _config.FileName; _config.LoadConfig(); }