private static void CreateTextBox(UIField field, ControlBase child) { var input = child as TextBox; field.Input = new UIInput { ID = input.ID, Name = input.Name, Class = input.Class, Style = input.Style, Options = input.Options, IsEnable = input.IsEnable, IsReadOnly = input.IsReadOnly, IsRequired = input.IsRequired, IsHidden = input.IsHidden, Binding = input.Binding, Length = input.Length }; }
private static void CreateComboBox(UIField field, ControlBase child) { var input = child as ComboBox; field.Input = new UIComboBox { ID = input.ID, Name = input.Name, Class = input.Class, Style = input.Style, Options = input.Options, IsEnable = input.IsEnable, IsReadOnly = input.IsReadOnly, IsRequired = input.IsRequired, IsHidden = input.IsHidden, Binding = input.Binding, DisplayMember = input.DisplayMemeber, ItemsSource = input.ItemsSource, Length = input.Length, ValueMember = input.ValueMember }; }
private UIDialog CreateDialogPage() { UIDialog page = new UIDialog { SettingType = "EditDialog" }; var fields = Form.GetAllChilds().Where(c => c is StackPanel && c.Class.Equals("edit-field", StringComparison.OrdinalIgnoreCase)); var unKnowControls = 0; #region 添加字段 foreach (StackPanel f in fields) { UIField field = new UIField(); bool inputCreate = false; foreach (var child in f.GetAllChilds()) { if (child is ComboBox) { if (inputCreate) { unKnowControls += 1; continue; } CreateComboBox(field, child); inputCreate = true; continue; } if (child is TextBox) { if (inputCreate) { unKnowControls += 1; continue; } CreateTextBox(field, child); inputCreate = true; continue; } if (child is Label) { field.Title = (child as Label).Title; continue; } unKnowControls += 1; } page.Form.Fields.Add(field); } #endregion var buttonPanel = Form.GetAllChilds() .FirstOrDefault(c => c is StackPanel && c.Class.Equals("dialog-button", StringComparison.OrdinalIgnoreCase)); if (buttonPanel != null) { var buttons = (buttonPanel as StackPanel).GetAllChilds().Where(c => c is Button); foreach (Button button in buttons) { page.Form.ToolBar.Buttons.Add(new UIButton { ID = button.ID, Class = button.Class, Name = button.Name, Title = button.Title, Action = button.Action, ActionValue = button.ActionValue, Options = button.Options, Style = button.Style }); } } var action = CommandConfig.ActionConfig as Panasia.Core.App.Action; var command = AppConfig.Current.CreateCommand(action); command.Name = this.Name + "copy"; command.CommandType = ActionCommands.EditDialogActionCommand; if (command.Config != null && command.Config is EditDialogActionCommand) { var pageCommand = command.Config as EditDialogActionCommand; pageCommand.Page = page; pageCommand.ContentType = ContentType; pageCommand.Encoding = this.Encoding; this.Parameters.AddToCollection(pageCommand.Parameters); } return(page); }