/// <summary> /// 构造tab顺序 /// </summary> private void BuildTabOrder() { List <TabOrderTrigger> triggers = new List <TabOrderTrigger>(); triggers.Add(new TabOrderTrigger(txtBarCode, null)); tabOrderManager = new TabOrderManager(triggers); tabOrderManager.Kind = TabOrderKind.循环; tabOrderManager.Reset(); }
/// <summary> /// 构造tab顺序 /// </summary> private void BuildTabOrder() { List <TabOrderTrigger> triggers = new List <TabOrderTrigger>(); triggers.Add(new TabOrderTrigger(txtUser, null)); triggers.Add(new TabOrderTrigger(cbOrgList, null)); triggers.Add(new TabOrderTrigger(txtPassword, null)); triggers.Add(new TabOrderTrigger(btnLogin, btnLogin_Click)); tabOrderManager = new TabOrderManager(triggers); tabOrderManager.Reset(); }
/// <summary> /// 构造tab顺序 /// </summary> private void BuildTabOrder() { List <TabOrderTrigger> triggers = new List <TabOrderTrigger>(); triggers.Add(new TabOrderTrigger(txtServiceUrl, null)); triggers.Add(new TabOrderTrigger(txtTimeout, null)); triggers.Add(new TabOrderTrigger(txtMaxConnCount, null)); triggers.Add(new TabOrderTrigger(btnOK, btnOK_Click)); tabOrderManager = new TabOrderManager(triggers); tabOrderManager.Reset(); }
/// <summary> /// Constructor, you should the method ShwDlg instead /// </summary> private YamuiInput(string htmlTitle, string htmlMessage, List <string> buttonsList, object dataObject, int formMaxWidth, int formMaxHeight, int formMinWidth, EventHandler <HtmlLinkClickedEventArgs> onLinkClicked) : base(YamuiFormOption.WithShadow) { InitializeComponent(); _tooltip = new HtmlToolTip(); var maxWidthInPanel = formMaxWidth - (Padding.Left + Padding.Right); contentPanel.DisableBackgroundImage = true; // if there was an object data passed on, need to check the max width needed to draw the inputs DataObject = dataObject; if (HasData) { // we make a list MemberInfo for each field in the data passed if (DataObject.GetType().IsSimpleType()) { _items.Add(null); } else { foreach (var mi in DataObject.GetType().GetMembers(BindingFlags.Instance | BindingFlags.Public)) { if (GetAttr(mi) != null && GetAttr(mi).Hidden) { continue; } var fi = mi as FieldInfo; var pi = mi as PropertyInfo; if (fi != null && Utilities.IsSupportedType(fi.FieldType)) { _items.Add(fi); } else if (pi != null && Utilities.IsSupportedType(pi.PropertyType) && pi.GetIndexParameters().Length == 0 && pi.CanWrite) { _items.Add(pi); } } _items.Sort((x, y) => (GetAttr(x) != null ? GetAttr(x).Order : int.MaxValue) - (GetAttr(y) != null ? GetAttr(y).Order : int.MaxValue)); } // redefine the minimum Form Width for each input we will need to display var widthSpace = InputDefaultWidth + InputPadding * 3 + Padding.Left + Padding.Right; for (int i = 0; i < _items.Count; i++) { var item = _items[i]; if (item != null) { _dataLabelWidth = _dataLabelWidth.ClampMin(Utilities.MeasureHtmlPrefWidth((GetAttr(item) != null ? GetAttr(item).Label : item.Name), 0, maxWidthInPanel - widthSpace)); } } formMinWidth = formMinWidth.ClampMin(_dataLabelWidth + widthSpace); } // Set title, it will define a new minimum width for the message box var space = FormButtonWidth * 2 + BorderWidth * 2 + titleLabel.Padding.Left + 5; titleLabel.SetNeededSize(htmlTitle, formMinWidth - space, formMaxWidth - space, true); var newPadding = Padding; newPadding.Top = titleLabel.Height + 10; Padding = newPadding; titleLabel.Location = new Point(5, 5); // Set buttons int cumButtonWidth = 0; for (int i = buttonsList.Count - 1; i >= 0; i--) { Controls.Add(InsertButton(i, buttonsList[i], ref cumButtonWidth)); } // set content label space = Padding.Left + Padding.Right; contentLabel.SetNeededSize(htmlMessage ?? string.Empty, (cumButtonWidth + ButtonPadding + BorderWidth * 2 + 20).ClampMin(formMinWidth - space), maxWidthInPanel); contentLabel.Width = (formMinWidth - space).ClampMin(contentLabel.Width); if (onLinkClicked != null) { contentLabel.LinkClicked += onLinkClicked; } contentLabel.Anchor = contentLabel.Anchor | AnchorStyles.Right; var yPos = contentLabel.Location.Y + contentLabel.Height; // ensure a minimum width if there is no message contentLabel.Width = (formMinWidth - space).ClampMin(contentLabel.Width); // if there was an object data passed on, need to set up inputs for the user to fill in if (HasData) { // Build rows for each item yPos += 10; for (int i = 0; i < _items.Count; i++) { contentPanel.Controls.Add(InsertInputForItem(i, ref yPos)); contentPanel.Controls.Add(InsertLabelForItem(i, ref yPos)); } } // set form size Size = new Size(contentLabel.Width + space, (Padding.Top + Padding.Bottom + yPos).ClampMax(formMaxHeight)); if (contentPanel.VerticalScroll.HasScroll) { _hasScrollMessage = true; Width += 10; } MinimumSize = Size; // quickly correct the tab order.. (we created the button from right to left and i'm too lazy to think atm) var tabOrderManager = new TabOrderManager(this); tabOrderManager.SetTabOrder(TabOrderManager.TabScheme.AcrossFirst); KeyPreview = true; }
/// <summary> /// Handles the Load event of the MainForm control. /// </summary> /// <param name="sender"> /// The source of the event. /// </param> /// <param name="e"> /// The <see cref="EventArgs"/> instance containing the event data. /// </param> private void MainFormLoad(object sender, EventArgs e) { var manager = new TabOrderManager(this); manager.SetTabOrder(TabOrderManager.TabScheme.AcrossFirst); Program.TopWindow(this); this.ShowLog(@"就绪.."); }