/// <summary> /// Converts the WinForm control into WiX custom UI control <see cref="T:WixSharp.Control" />. /// </summary> /// <returns> /// Instance of the WixSharp.Control. /// </returns> public virtual Wix.Controls.Control ToWControl() { Wix.Controls.Control retval = this.ConvertToWControl(ControlType.Text); //if (NoPrefix) // retval.AttributesDefinition += ";NoPrefix=yes"; return(retval); }
/// <summary> /// Converts <see cref="IWixControl"/> into an instance of <see cref="WixSharp.Controls.Control"/>. /// </summary> /// <param name="srcControl">The source control.</param> /// <param name="controlType">Type of the control.</param> /// <returns></returns> public static WixSharp.Controls.Control ConvertToWControl(this IWixControl srcControl, ControlType controlType) { var wControl = new WixSharp.Controls.Control { Type = controlType.ToString() }; wControl.CopyCommonPropertiesFrom(srcControl); return(wControl); }
/// <summary> /// Converts the WinForm control into WiX custom UI control <see cref="T:WixSharp.Control" />. /// </summary> /// <returns> /// Instance of the WixSharp.Control. /// </returns> /// <exception cref="System.ApplicationException">WixTextBox (' + control.Id + ') must have BoundProperty set to non-empty value.</exception> public virtual Wix.Controls.Control ToWControl() { Wix.Controls.Control control = this.ConvertToWControl(ControlType.Edit); if (BoundProperty.IsEmpty()) { throw new ApplicationException("WixTextBox ('" + control.Id + "') must have BoundProperty set to non-empty value."); } return(control); }
/// <summary> /// Copies the common properties from one <see cref="IWixControl"/> to another. /// </summary> /// <param name="destControl">The dest control.</param> /// <param name="srcControl">The source control.</param> public static void CopyCommonPropertiesFrom(this WixSharp.Controls.Control destControl, IWixControl srcControl) { var formControl = (System.Windows.Forms.Control)srcControl; if (srcControl.Conditions != null) { destControl.Conditions.AddRange(srcControl.Conditions); } destControl.Height = formControl.Size.Height.WScale(); destControl.Width = formControl.Size.Width.WScale(); destControl.X = formControl.Left.WScale(); destControl.Y = formControl.Top.WScale(); destControl.Disabled = !formControl.Enabled; destControl.Hidden = srcControl.Hidden; destControl.AttributesDefinition = srcControl.WixAttributes; destControl.Property = srcControl.BoundProperty; if (srcControl is WixControl) { destControl.EmbeddedXML = (srcControl as WixControl).EmbeddedXML; } if (!formControl.Text.IsEmpty()) { destControl.Text = formControl.Text; } if (!srcControl.Tooltip.IsEmpty()) { destControl.Tooltip = srcControl.Tooltip; } destControl.Name = formControl.Name.IsNullOrEmpty() ? destControl.Type : formControl.Name; if (!srcControl.Id.IsNullOrEmpty()) { destControl.Id = srcControl.Id; //destControl.Id is a calculated property and if not set explicitly it will fell back to the destControl.Name } if (srcControl is IWixInteractiveControl) { destControl.Actions.AddRange((srcControl as IWixInteractiveControl).Actions); } }
/// <summary> /// Converts the WinForm control into WiX custom UI control <see cref="T:WixSharp.Control" />. /// </summary> /// <returns> /// Instance of the WixSharp.Control. /// </returns> /// <exception cref="System.ApplicationException">WixCheckBox (' + control.Id + ') must have BoundProperty set to non-empty value.</exception> public virtual Wix.Controls.Control ToWControl() { Wix.Controls.Control control = this.ConvertToWControl(ControlType.CheckBox); //It is tempting to allow WiX compiler report the problem. However WiX is not reliable with the error reporting. //For example it does it for "CheckBox" but not for "Edit" //Note that control.Name is a better identity value than this.Name, which can be empty. if (BoundProperty.IsEmpty()) { throw new ApplicationException("WixCheckBox ('" + control.Id + "') must have BoundProperty set to non-empty value."); } if (!CheckBoxValue.IsEmpty()) { control.AttributesDefinition += ";CheckBoxValue=" + CheckBoxValue; } return(control); }