/// <summary> /// Constructor of the Codes dialog /// </summary> /// <param name="frm">The main form</param> /// <param name="field">The field</param> /// <param name="currentPage">The current page</param> public ListDialog(MainForm frm, RenderableField field, Page currentPage) : base(frm, field, currentPage) { InitializeComponent(); page = currentPage; ddlField = (DDListField)field; codeTable = ddlField.GetSourceData(); this.Text = "List Field"; //cbxSort.Checked = ddlField.ShouldSort; fieldName = ddlField.Name; SetDataSource(ddlField); SetDgCodes(dgCodes, fieldName); }
protected virtual FieldFlags SetFieldFlags(Epi.Fields.RenderableField field) { FieldFlags flags = new FieldFlags(false, false, false, false); if (field is TableBasedDropDownField || field is YesNoField || field is CheckBoxField) { flags.IsDropDownListField = true; if (field is DDLFieldOfCommentLegal) { flags.IsCommentLegalField = true; } } else if (field is OptionField) { flags.IsOptionField = true; } return(flags); }
/// <summary> /// Constructor for the Comment Legal dialog /// </summary> /// <param name="field">The comment legal field</param> /// <param name="currentPage">The current page</param> public CommentLegalDialog(RenderableField field, Page currentPage) : base(field, currentPage) { InitializeComponent(); page = currentPage; DDLFieldOfCommentLegal ddlField = (DDLFieldOfCommentLegal)field; codeTable = ddlField.GetSourceData(); //if (dgCodes.AllowSorting) //{ // ddlField.ShouldSort = true; //} //else //{ // ddlField.ShouldSort = false; //} dgCodes.DataSource = codeTable; sourceTableName = codeTable.TableName; textColumnName = fieldName; //dgCodes.AllowSorting = true; }
private void SetControlProperties(System.Windows.Forms.MaskedTextBox control, RenderableField field, Size canvasSize) { control.Left = WinUtil.GetControlLeft(field, canvasSize.Width); control.Top = WinUtil.GetControlTop(field, canvasSize.Height); if (field.ControlHeightPercentage > 0) { control.Height = WinUtil.GetControlHeight(field, canvasSize.Height); } if (field.ControlWidthPercentage > 0) { control.Width = WinUtil.GetControlWidth(field, canvasSize.Width); } if (field is FieldWithSeparatePrompt) { FieldWithSeparatePrompt promptField = (FieldWithSeparatePrompt)field; int promptWidth = TextRenderer.MeasureText(field.PromptText, field.PromptFont).Width; int promptRight = WinUtil.GetPromptLeft(promptField, canvasSize.Width) + promptWidth; } if(((InputFieldWithSeparatePrompt)field).IsReadOnly) { control.Enabled = false; } else { control.Enabled = field.IsEnabled; } control.Visible = field.IsVisible; if (field.IsHighlighted) { control.BackColor = Canvas.HighlightColor; } control.TabStop = field.HasTabStop; control.TabIndex = (int)field.TabIndex; control.Font = field.ControlFont; control.CausesValidation = true; _controlFields.Add(control, field); }
private void SetControlProperties(Control control, RenderableField field, Size canvasSize) { control.Left = WinUtil.GetControlLeft(field, canvasSize.Width); control.Top = WinUtil.GetControlTop(field, canvasSize.Height); if (field.ControlHeightPercentage > 0) { control.Height = WinUtil.GetControlHeight(field, canvasSize.Height); } if (field.ControlWidthPercentage > 0) { control.Width = WinUtil.GetControlWidth(field, canvasSize.Width); } control.TabStop = field.HasTabStop; control.TabIndex = (int)field.TabIndex; if ((field is OptionField) == false) { control.Font = field.ControlFont; } control.Name = field.Name; if (control is DragableLabel == false) { control.BackColor = SystemColors.Window; } else { control.CausesValidation = true; } if (field is InputFieldWithSeparatePrompt) { control.CausesValidation = true; if (((InputFieldWithSeparatePrompt)field).IsReadOnly) { control.Enabled = false; } else { control.Enabled = field.IsEnabled; } } else if (field is InputFieldWithoutSeparatePrompt) { control.CausesValidation = true; if (((InputFieldWithoutSeparatePrompt)field).IsReadOnly) { control.Enabled = false; } else { control.Enabled = field.IsEnabled; } } else { control.Enabled = field.IsEnabled; } control.Visible = field.IsVisible; if (field.IsHighlighted) { control.BackColor = Canvas.HighlightColor; } _controlFields.Add(control, field); }
/// <summary> /// Updates the control size /// </summary> /// <param name="field">field</param> public void UpdateControlSize(RenderableField field) { try { Query query = db.CreateQuery("update metaFields set [ControlHeightPercentage] = @Height, [ControlWidthPercentage] = @Width where [FieldId] = @FieldId"); query.Parameters.Add(new QueryParameter("@Height", DbType.Double, field.ControlHeightPercentage)); query.Parameters.Add(new QueryParameter("@Width", DbType.Double, field.ControlWidthPercentage)); query.Parameters.Add(new QueryParameter("@FieldId", DbType.Int32, field.Id)); db.ExecuteNonQuery(query); } catch (Exception ex) { throw new GeneralException("Could not update control size", ex); } finally { } }
//int fieldId, double xCoordinate, double yCoordinate) /// <summary> /// Updates the control position /// </summary> /// <param name="field">the field</param> // public void UpdateControlPosition(int fieldId, double xCoordinate, double yCoordinate) public void UpdateControlPosition(RenderableField field) { try { Query query = db.CreateQuery("update metaFields set [ControlLeftPositionPercentage] = @LeftPosition, [ControlTopPositionPercentage] = @TopPosition where [UniqueId] = @UniqueId"); query.Parameters.Add(new QueryParameter("@LeftPosition", DbType.Double, field.ControlLeftPositionPercentage)); query.Parameters.Add(new QueryParameter("@TopPosition", DbType.Double, field.ControlTopPositionPercentage)); query.Parameters.Add(new QueryParameter("@UniqueId", DbType.Guid, field.UniqueId)); db.ExecuteNonQuery(query); } catch (Exception ex) { throw new GeneralException("Could not update control position", ex); } }
public LegalValuesDialog(MainForm frm, RenderableField field, Page currentPage) : base(frm) { InitializeComponent(); page = currentPage; ddlField = (DDLFieldOfLegalValues)field; codeTable = ddlField.GetSourceData(); cbxSort.Checked = ddlField.ShouldSort; fieldName = ddlField.Name; //dgCodes.PreferredColumnWidth = Convert.ToInt32(dgCodes.Width * COLUMN_WIDTH_MULTIPLE); }
public LegalValuesDialog(RenderableField field, Page currentPage) { InitializeComponent(); if (string.IsNullOrEmpty(field.ToString())) { throw new ArgumentNullException("field"); } if (string.IsNullOrEmpty(currentPage.ToString())) { throw new ArgumentNullException("currentPage"); } ddlField = (DDLFieldOfLegalValues)field; page = currentPage; codeTable = ddlField.GetSourceData(); cbxSort.Checked = ddlField.ShouldSort; fieldName = ddlField.Name; sourceTableName = ddlField.SourceTableName; textColumnName = ddlField.TextColumnName; }
/// <summary> /// Updates the control size /// </summary> /// <param name="field">field</param> public void UpdateControlSize(RenderableField field) { try { XmlDocument doc = this.Project.GetXmlDocument(); XmlNode viewsNode = GetViewsNode(); XmlNode fieldsNode = viewsNode.SelectSingleNode("//View/Fields"); XmlNode fieldNode = fieldsNode.SelectSingleNode("//Field[@FieldId= '" + field.Id + "']"); fieldNode.Attributes["ControlHeightPercentage"].Value = field.ControlHeightPercentage.ToString(); fieldNode.Attributes["ControlWidthPercentage"].Value = field.ControlWidthPercentage.ToString(); this.Project.Save(); } catch (Exception ex) { throw new GeneralException("Could not update control size", ex); } finally { } }
private void AdjustCheckboxWidth(RenderableField field) { //Graphics g = Graphics.FromHwnd(canvas.Handle); //int currentWidth = Convert.ToInt32(canvas.Width * field.ControlWidthPercentage); //Size textSize = TextRenderer.MeasureText(g, field.PromptText, field.PromptFont); ////add some width for the checkbox and make sure it doesn't wrap //textSize.Width += 40; //int leftPosition = (int)Math.Ceiling(canvas.PagePanel.Size.Width * field.ControlLeftPositionPercentage); //double adjustedWidthPercent = (double)textSize.Width / (double)canvas.PagePanel.Size.Width; //if (field.ControlWidthPercentage < adjustedWidthPercent) //{ // if (adjustedWidthPercent > 1) // adjustedWidthPercent = 1.0; // field.ControlWidthPercentage = adjustedWidthPercent; //} }
private bool ShouldUseDefaultPromptFont(RenderableField field) { if ((field.PromptFont == null) || ((field.PromptFont.Name == "Microsoft Sans Serif") && (field.PromptFont.Size == 8.5))) { return true; } else { return false; } }
protected void SetFontStyles(RenderableField field) { if (ShouldUseDefaultPromptFont(field)) { Configuration config = Configuration.GetNewInstance(); FontStyle promptFontStyle = FontStyle.Regular; if (config.Settings.EditorFontBold) { promptFontStyle |= FontStyle.Bold; } if (config.Settings.EditorFontItalics) { promptFontStyle |= FontStyle.Italic; } field.PromptFont = new Font(config.Settings.EditorFontName, (float)config.Settings.EditorFontSize, promptFontStyle); } if (ShouldUseDefaultControlFont(field)) { Configuration config = Configuration.GetNewInstance(); FontStyle controlFontStyle = FontStyle.Regular; if (config.Settings.ControlFontBold) { controlFontStyle |= FontStyle.Bold; } if (config.Settings.ControlFontItalics) { controlFontStyle |= FontStyle.Italic; } field.ControlFont = new Font(config.Settings.ControlFontName, (float)config.Settings.ControlFontSize, controlFontStyle); } promptFont = field.PromptFont; controlFont = field.ControlFont; }
///// <summary> ///// Adds a new group field to the page ///// </summary> ///// <param name="field">Field to add</param> //public void AddNewGroupField(FieldGroup field) //{ // field.Page = this; // view.MustRefreshFieldCollection = true; //} /// <summary> /// Updates Renderable Field. /// </summary> /// <param name="field">The field that is updated</param> public void UpdateField(RenderableField field) { if (!((field is MirrorField) || (field is LabelField))) { field.HasTabStop = true; field.TabIndex = MaxTabIndex + 1; } field.SaveToDb(); }
/// <summary> /// Adds a new field to the page /// </summary> /// <param name="field">Field to add</param> public void AddNewField(RenderableField field) { field.Page = this; if (!((field is MirrorField) || (field is LabelField))) { field.HasTabStop = true; field.TabIndex = MaxTabIndex + 1; } field.SaveToDb(); // Invalidate the current in-memory field collections and force the app to retreive // a fresh collection from the database whenever Page.Fields or Page.RenderableFields // is invoked. view.MustRefreshFieldCollection = true; }