private void MainForm_Load(object sender, EventArgs e) { foreach (var toolName in ToolMapping.GetToolNames()) { this.treeView_Tools.Nodes[0].Nodes.Add(toolName); } this.treeView_Tools.ExpandAll(); }
private void treeView_Tools_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) { this.CurrentToolName = e.Node.Text; this.tabControl1.SelectedTab.Text = CurrentToolName; var viewPath = ToolMapping.GetViewPath(this.CurrentToolName); if (!(this.tabControl1.SelectedTab.Controls[0] is WebBrowser activeWebBrowser)) { return; } activeWebBrowser.Url = new Uri(viewPath.ViewPath); }
public void AppendTabPageForTool(string currentToolName) { var viewPath = ToolMapping.GetViewPath(currentToolName); var webBrowser = new WebBrowser { ObjectForScripting = this, Dock = DockStyle.Fill, Url = new Uri(viewPath.ViewPath) }; var tabPage = new TabPage(CurrentToolName); tabPage.Controls.Add(webBrowser); this.tabControl1.TabPages.Add(tabPage); this.tabControl1.SelectTab(tabPage); }
public void HandlerProcess(string handlerArgsStr, WebBrowser currentWebBrowser) { try { var requestMethodArgs = JsonConvert.DeserializeObject <RequestMethodArgs>(handlerArgsStr); var t = Type.GetType(ToolMapping.GetViewPath(this.CurrentToolName).HandlerFullName); var handler = Activator.CreateInstance(t ?? throw new InvalidOperationException($"未找到{CurrentToolName}Handler."), currentWebBrowser); t.GetMethod(requestMethodArgs.MethodName)?.Invoke(handler, new[] { requestMethodArgs.ArgsJsonStr }); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public MainForm() { InitializeComponent(); this.treeView_Tools.Nodes.Add("Tools"); #region Events this.Load += MainForm_Load; this.tabControl1.MouseDoubleClick += TabControl1_MouseDoubleClick; #endregion this._webBrowser.ObjectForScripting = this; this.treeView_Tools.HideSelection = false; ToolMapping.Init(); }