public TextField TextField(int x, int y, int sizeX, int sizeY, Color textColor, SpriteFont font, ARenderStyle style, string hint = null, IHorizontalAlignable horizontalAlignment = null, IVerticalAlignable verticalAlignment = null, IAlignmentTransition alignmentTransition = null, IColorPattern pattern = null, TextAppenderHelper appender = null) { TextField textField = null; return(textField = controlFactory.CreateTextBox(appender ?? TextAppenderHelper.Default, font, GetTexture(sizeX, sizeY, pattern), new Region(new Vector2(x, y), new Vector2(sizeX, sizeY)), textColor, style, hint ?? string.Empty, horizontalAlignment ?? HorizontalAlignment.Left, verticalAlignment ?? VerticalAlignment.Center, alignmentTransition ?? AlignmentTransition.Instant)); }
///<summary> /// A constructor for the <see cref="ErrorDescriptionForm"/> ///</summary> public ErrorDescriptionForm() { IControlFactory controlFactory = GlobalUIRegistry.ControlFactory; ILabel label = controlFactory.CreateLabel("Please enter further details regarding the error : "); _errorDescriptionTextBox = controlFactory.CreateTextBox(); ErrorDescriptionTextBox.Multiline = true; IButtonGroupControl buttonGroupControl = controlFactory.CreateButtonGroupControl(); buttonGroupControl.AddButton("OK", delegate { this.Close(); }); BorderLayoutManager layoutManager = controlFactory.CreateBorderLayoutManager(this); layoutManager.AddControl(label, BorderLayoutManager.Position.North); layoutManager.AddControl(ErrorDescriptionTextBox, BorderLayoutManager.Position.Centre); layoutManager.AddControl(buttonGroupControl, BorderLayoutManager.Position.South); this.Text = "Error Description"; this.Width = 500; this.Height = 400; this.Closing += delegate(object sender, CancelEventArgs e) { if (ErrorDescriptionFormClosing == null) { return; } ErrorDescriptionFormClosing(sender, e); }; }
///<summary> /// Constructor for <see cref="StringTextBoxFilter"/> ///</summary> ///<param name="controlFactory"></param> ///<param name="propertyName"></param> ///<param name="filterClauseOperator"></param> public StringTextBoxFilter(IControlFactory controlFactory, string propertyName, FilterClauseOperator filterClauseOperator) { _controlFactory = controlFactory; _propertyName = propertyName; _filterClauseOperator = filterClauseOperator; _textBox = _controlFactory.CreateTextBox(); _textBox.TextChanged += (sender, e) => FireValueChanged(); }
public CustomFilterStub(IControlFactory factory) { _factory = factory; _box = _factory.CreateTextBox(); ValueChanged += CustomFilterStub_ValueChanged; _box.TextChanged += ValueChanged; _valueChangedFired = false; }
///<summary> /// Constructor for <see cref="MultiplePropStringTextBoxFilter"/> ///</summary> ///<param name="controlFactory"></param> ///<param name="propertyNames"></param> ///<param name="filterClauseOperator"></param> public MultiplePropStringTextBoxFilter(IControlFactory controlFactory, List<string> propertyNames, FilterClauseOperator filterClauseOperator) { _controlFactory = controlFactory; _propertyNames = propertyNames; _propertyNames.Sort((s, s1) => s1.CompareTo(s)); _filterClauseOperator = filterClauseOperator; _textBox = _controlFactory.CreateTextBox(); _textBox.TextChanged += (sender, e) => FireValueChanged(); }
///<summary> /// Constructor for <see cref="MultiplePropStringTextBoxFilter"/> ///</summary> ///<param name="controlFactory"></param> ///<param name="propertyNames"></param> ///<param name="filterClauseOperator"></param> public MultiplePropStringTextBoxFilter(IControlFactory controlFactory, List <string> propertyNames, FilterClauseOperator filterClauseOperator) { _controlFactory = controlFactory; _propertyNames = propertyNames; _propertyNames.Sort((s, s1) => s1.CompareTo(s)); _filterClauseOperator = filterClauseOperator; _textBox = _controlFactory.CreateTextBox(); _textBox.TextChanged += (sender, e) => FireValueChanged(); }
///<summary> /// Constructs the <see cref="FileChooserManager"/> ///</summary> ///<param name="controlFactory"></param> ///<param name="fileChooser"></param> public FileChooserManager(IControlFactory controlFactory, IFileChooser fileChooser) { _controlFactory = controlFactory; _fileChooser = fileChooser; FlowLayoutManager manager = new FlowLayoutManager(_fileChooser, _controlFactory); _fileTextBox = _controlFactory.CreateTextBox(); _selectFileButton = _controlFactory.CreateButton("Select...", null); manager.AddControl(_fileTextBox); manager.AddControl(_selectFileButton); }
///<summary> /// Constructor with a specified Control Factory ///</summary> ///<param name="factory"></param> public ExtendedTextBoxWin(IControlFactory factory) { Button = factory.CreateButton("..."); TextBox = factory.CreateTextBox(); Button.MinimumSize = new Size(0, 0); TextBox.Enabled = false; this.Height = TextBox.Height; BorderLayoutManager borderLayoutManager = factory.CreateBorderLayoutManager(this); this.Padding = Padding.Empty; borderLayoutManager.AddControl(TextBox, BorderLayoutManager.Position.Centre); borderLayoutManager.AddControl(Button, BorderLayoutManager.Position.East); }
/// <summary> /// Initialises the form with a message to display to the user. /// </summary> /// <param name="controlFactory">The <see cref="IControlFactory"/> to use to create the form</param> /// <param name="message">The message to display</param> /// <param name="numLines">The number of lines to make available</param> /// <param name="passwordChar">The Char to use if the Textbox is to be used as a password field</param> public InputFormTextBox(IControlFactory controlFactory, string message, int numLines, char passwordChar) { _controlFactory = controlFactory; _message = message; _textBox = _controlFactory.CreateTextBox(); _textBox.PasswordChar = passwordChar; if (numLines > 1) { _textBox.Multiline = true; _textBox.Height = _textBox.Height * numLines; _textBox.ScrollBars = ScrollBars.Vertical; } }
#pragma warning disable 168 public SimpleFilterStub (IControlFactory controlFactory, string propertyName, FilterClauseOperator filterClauseOperator) #pragma warning restore 168 { _textBox = controlFactory.CreateTextBox(); }
public void TestShowDatePickersFormWithVisualStyles() { //---------------Set up test pack------------------- //Application.EnableVisualStyles(); IFormHabanero formWin = new FormWin(); IControlFactory controlFactory = GetControlFactory(); IDateTimePicker dateTimePicker = controlFactory.CreateDateTimePicker(); dateTimePicker.Format = Habanero.Faces.Base.DateTimePickerFormat.Custom; dateTimePicker.CustomFormat = @"dddd MMMM yyyy"; dateTimePicker.NullDisplayValue = "Please Click"; //dateTimePicker.ShowCheckBox = true; ITextBox textBox = controlFactory.CreateTextBox(); IButton button = controlFactory.CreateButton("Check/Uncheck", delegate { //dateTimePicker.Checked = !dateTimePicker.Checked; if (dateTimePicker.ValueOrNull.HasValue) { dateTimePicker.ValueOrNull = null; } else { dateTimePicker.ValueOrNull = dateTimePicker.Value; } }); IButton enableButton = controlFactory.CreateButton("Enable/Disable", delegate { dateTimePicker.Enabled = !dateTimePicker.Enabled; }); IPanel panel = controlFactory.CreatePanel(); panel.Dock = DockStyle.Fill; formWin.Controls.Add(panel); GridLayoutManager gridLayoutManager = new GridLayoutManager(panel, controlFactory); gridLayoutManager.SetGridSize(9, 1); gridLayoutManager.BorderSize = 25; gridLayoutManager.AddControl(dateTimePicker); gridLayoutManager.AddControl(button); gridLayoutManager.AddControl(textBox); gridLayoutManager.AddControl(enableButton); gridLayoutManager.AddControl(controlFactory.CreateButton("ChangeColor", delegate { Random random = new Random(); dateTimePicker.ForeColor = Color.FromArgb(random.Next(0, 255), random.Next(0, 255), random.Next(0, 255)); dateTimePicker.BackColor = Color.FromArgb(random.Next(0, 255), random.Next(0, 255), random.Next(0, 255)); })); IDateTimePicker anotherDateTimePicker; anotherDateTimePicker = controlFactory.CreateDateTimePicker(); anotherDateTimePicker.Format = Habanero.Faces.Base.DateTimePickerFormat.Long; gridLayoutManager.AddControl(anotherDateTimePicker); anotherDateTimePicker = controlFactory.CreateDateTimePicker(); anotherDateTimePicker.Format = Habanero.Faces.Base.DateTimePickerFormat.Short; gridLayoutManager.AddControl(anotherDateTimePicker); anotherDateTimePicker = controlFactory.CreateDateTimePicker(); anotherDateTimePicker.Format = Habanero.Faces.Base.DateTimePickerFormat.Time; gridLayoutManager.AddControl(anotherDateTimePicker); anotherDateTimePicker = controlFactory.CreateDateTimePicker(); anotherDateTimePicker.Format = Habanero.Faces.Base.DateTimePickerFormat.Long; anotherDateTimePicker.Font = new Font(FontFamily.GenericSansSerif, 18); anotherDateTimePicker.Height = 60; gridLayoutManager.AddControl(anotherDateTimePicker); dateTimePicker.ValueChanged += delegate { textBox.Text = dateTimePicker.ValueOrNull.HasValue ? dateTimePicker.Value.ToString() : ""; }; //---------------Execute Test ---------------------- formWin.ShowDialog(); //---------------Test Result ----------------------- //---------------Tear down ------------------------- }
/// <summary> /// Creates a panel with the controls and dimensions as prescribed /// </summary> /// <param name="uiFormTab">The UIFormTab object</param> /// <returns>Returns the object containing the new panel</returns> private IPanelFactoryInfo CreateOnePanel(IUIFormTab uiFormTab) { if (uiFormTab.UIFormGrid != null) { return(CreatePanelWithGrid(uiFormTab.UIFormGrid)); } IPanel panel = _controlFactory.CreatePanel(_controlFactory); IToolTip toolTip = _controlFactory.CreateToolTip(); GridLayoutManager manager = new GridLayoutManager(panel, _controlFactory); int rowCount = 0; int colCount = 0; colCount += uiFormTab.Count; foreach (UIFormColumn uiFormColumn in uiFormTab) { if (uiFormColumn.Count > rowCount) { rowCount = uiFormColumn.Count; } } const int intNoOfLayoutGridColumnsPerPanel = 3; manager.SetGridSize(rowCount, colCount * intNoOfLayoutGridColumnsPerPanel); for (int col = 0; col < colCount; col++) { //Fixing the labels column widths manager.FixColumnBasedOnContents(col * intNoOfLayoutGridColumnsPerPanel); } ControlMapperCollection controlMappers = new ControlMapperCollection(); controlMappers.BusinessObject = _currentBusinessObject; ITextBox temptb = _controlFactory.CreateTextBox(); for (int row = 0; row < rowCount; row++) { manager.FixRow(row, temptb.Height); } manager.FixAllRowsBasedOnContents(); GridLayoutManager.ControlInfo[,] controls = new GridLayoutManager.ControlInfo[rowCount, colCount *intNoOfLayoutGridColumnsPerPanel]; int currentColumn = 0; foreach (UIFormColumn uiFormColumn in uiFormTab) { int currentRow = 0; foreach (UIFormField field in uiFormColumn) { bool isCompulsory; ClassDef classDef = _currentBusinessObject.ClassDef; PropDef propDef = (PropDef)field.GetPropDefIfExists(classDef); if (propDef != null) { isCompulsory = propDef.Compulsory; } else { isCompulsory = false; } string labelCaption = field.GetLabel(classDef); // BOPropCol boPropCol = _currentBusinessObject.Props; // if (boPropCol.Contains(field.PropertyName)) // { // IBOProp boProp = boPropCol[field.PropertyName]; // if (!boProp.HasDisplayName()) // { // boProp.DisplayName = labelCaption; // } // } IControlHabanero ctl = CreateControl(field, _controlFactory); bool editable = CheckIfEditable(field, ctl); ILabel labelControl = _controlFactory.CreateLabel(labelCaption, isCompulsory && editable); controls[currentRow, currentColumn + 0] = new GridLayoutManager.ControlInfo(labelControl); if (ctl is ITextBox && propDef != null) { if (propDef.PropertyType == typeof(bool)) { ctl = _controlFactory.CreateCheckBox(); } else if (propDef.PropertyType == typeof(string) && propDef.KeepValuePrivate) { ctl = _controlFactory.CreatePasswordTextBox(); } else if (field.GetParameterValue("numLines") != null) { int numLines; try { numLines = Convert.ToInt32(field.GetParameterValue("numLines")); } catch (Exception) { throw new InvalidXmlDefinitionException ("An error " + "occurred while reading the 'numLines' parameter " + "from the class definitions. The 'value' " + "attribute must be a valid integer."); } if (numLines > 1) { ctl = _controlFactory.CreateTextBoxMultiLine(numLines); } } } if (ctl is ITextBox) { if (field.GetParameterValue("isEmail") != null) { string isEmailValue = (string)field.GetParameterValue("isEmail"); if (isEmailValue != "true" && isEmailValue != "false") { throw new InvalidXmlDefinitionException ("An error " + "occurred while reading the 'isEmail' parameter " + "from the class definitions. The 'value' " + "attribute must hold either 'true' or 'false'."); } //bool isEmail = Convert.ToBoolean(isEmailValue); //if (isEmail) //{ // ITextBox tb = (ITextBox) ctl; // tb.DoubleClick += _emailTextBoxDoubleClickedHandler; //} } } //if (ctl is IDateTimePicker) //{ // IDateTimePicker editor = (IDateTimePicker) ctl; // editor.Enter += DateTimePickerEnterHandler; //} //if (ctl is INumericUpDown) //{ // INumericUpDown upDown = (INumericUpDown) ctl; // upDown.Enter += UpDownEnterHandler; //} CheckGeneralParameters(field, ctl); IControlMapper ctlMapper = ControlMapper.Create (field.MapperTypeName, field.MapperAssembly, ctl, field.PropertyName, !editable, _controlFactory); if (ctlMapper is ControlMapper) { ControlMapper controlMapper = (ControlMapper)ctlMapper; controlMapper.SetPropertyAttributes(field.Parameters); } controlMappers.Add(ctlMapper); ctlMapper.BusinessObject = _currentBusinessObject; int colSpan = 1; if (field.GetParameterValue("colSpan") != null) { try { colSpan = Convert.ToInt32(field.GetParameterValue("colSpan")); } catch (Exception) { throw new InvalidXmlDefinitionException ("An error " + "occurred while reading the 'colSpan' parameter " + "from the class definitions. The 'value' " + "attribute must be a valid integer."); } } colSpan = (colSpan - 1) * intNoOfLayoutGridColumnsPerPanel + 1; // must span label columns too int rowSpan = 1; if (field.GetParameterValue("rowSpan") != null) { try { rowSpan = Convert.ToInt32(field.GetParameterValue("rowSpan")); } catch (Exception) { throw new InvalidXmlDefinitionException ("An error " + "occurred while reading the 'rowSpan' parameter " + "from the class definitions. The 'value' " + "attribute must be a valid integer."); } } if (rowSpan == 1) { manager.FixRow(currentRow, ctl.Height); } controls[currentRow, currentColumn + 1] = new GridLayoutManager.ControlInfo(ctl, rowSpan, colSpan); currentRow++; string toolTipText = field.GetToolTipText(classDef); if (!String.IsNullOrEmpty(toolTipText)) { toolTip.SetToolTip(labelControl, toolTipText); toolTip.SetToolTip(ctl, toolTipText); } //Hack brett trying to fix prob with dynamic properties ctl.Width = 100; } currentColumn += 3; } for (int i = 0; i < rowCount; i++) { for (int j = 0; j < colCount * intNoOfLayoutGridColumnsPerPanel; j++) { if (controls[i, j] == null) { manager.AddControl(null); } else { manager.AddControl(controls[i, j]); controls[i, j].Control.TabIndex = rowCount * j + i; } } } for (int col = 0; col < colCount; col++) { if (uiFormTab[col].Width > -1) { //Fix width of the control column e.g. textbox or combobox. manager.FixColumn(col * intNoOfLayoutGridColumnsPerPanel + 1, uiFormTab[col].Width - manager.GetFixedColumnWidth(col * intNoOfLayoutGridColumnsPerPanel)); } manager.FixColumn(col * intNoOfLayoutGridColumnsPerPanel + 2, 15); } panel.Height = manager.GetFixedHeightIncludingGaps(); panel.Width = manager.GetFixedWidthIncludingGaps(); IPanelFactoryInfo panelFactoryInfo = new PanelFactoryInfo(panel, controlMappers, _uiDefName, _firstControl); panelFactoryInfo.MinimumPanelHeight = panel.Height; panelFactoryInfo.MinumumPanelWidth = panel.Width; panelFactoryInfo.ToolTip = toolTip; panelFactoryInfo.PanelTabText = uiFormTab.Name; panelFactoryInfo.UIForm = _uiForm; panelFactoryInfo.UiFormTab = uiFormTab; return(panelFactoryInfo); }