/// <summary> /// 新增按钮。 /// </summary> private void toolbarNew_Click(object sender, EventArgs e) { foreach (IViewContent viewContent in WorkbenchSingleton.Workbench.ViewContentCollection) { if (viewContent.TitleName == StringParser.Parse("${res:FanHai.Hemera.Addins.FMM.RouteViewContent.TitleName}")) { viewContent.WorkbenchWindow.SelectWindow(); RouteCtrl ctrl = (RouteCtrl)viewContent.Control.Controls.Find("RouteCtrl", true)[0]; if (ctrl.txtRouteName.Text.Trim() != "") { if (MessageBox.Show(StringParser.Parse("${res:Global.ClearNoteMessage}"), StringParser.Parse("${res:Global.SystemInfo}"), MessageBoxButtons.OKCancel) == DialogResult.Cancel) { return; } } ctrl.CtrlState = ControlState.New; return; } } RouteViewContent routeContent = new RouteViewContent(new RouteEntity()); WorkbenchSingleton.Workbench.ShowView(routeContent); }
/// <summary> /// 构造函数。 /// </summary> /// <param name="route">表示途程信息的实体对象。</param> public RouteViewContent(RouteEntity route) : base() { if (null != route && route.RouteName.Length > 0) { this.TitleName = StringParser.Parse("${res:FanHai.Hemera.Addins.FMM.RouteViewContent.TitleName}") + "_" + route.RouteName + "." + route.RouteVersion; } else { this.TitleName = StringParser.Parse("${res:FanHai.Hemera.Addins.FMM.RouteViewContent.TitleName}"); } Panel panel = new Panel(); //set panel dock style panel.Dock = DockStyle.Fill; //set panel BorderStyle panel.BorderStyle = BorderStyle.FixedSingle; RouteCtrl routeCtrl = new RouteCtrl(route); routeCtrl.Dock = DockStyle.Fill; //将控件对象加入到Panel中。 //设置Panel为该视图对象的控件对象,用于在应用程序平台上显示可视化的视图界面。 panel.Controls.Add(routeCtrl); //set panel to view content this.control = panel; }