// ========================================================================================= // Constructors // ========================================================================================= /// <summary> /// Initializes a new instance of the <see cref="WixBuildEventEditorForm"/> class. /// </summary> public WixBuildEventEditorForm(IServiceProvider serviceProvider) { this.serviceProvider = serviceProvider; this.InitializeComponent(); this.HelpRequested += new HelpEventHandler(this.WixBuildEventEditorForm_HelpRequested); this.Font = WixHelperMethods.GetDialogFont(); this.BackColor = WixHelperMethods.GetVsColor(WixHelperMethods.Vs2010Color.VSCOLOR_BUTTONFACE); WixHelperMethods.SetControlTreeColors(this); }
private void AddFolderButton_Click(object sender, EventArgs e) { string folder = WixHelperMethods.EnsureTrailingDirectoryChar(this.folderTextBox.Text); if (this.pathsListBox.FindStringExact(folder) == ListBox.NoMatches) { CancelEventArgs ce = new CancelEventArgs(); this.OnFolderValidating(ce); if (!ce.Cancel) { this.folderTextBox.Text = folder; this.pathsListBox.SelectedIndex = this.pathsListBox.Items.Add(folder); this.OnFoldersChanged(EventArgs.Empty); } } }
private void GenerateButtonImages() { Color grayColor = SystemColors.ControlDark; this.highContrastMode = SystemInformation.HighContrast; if (this.highContrastMode) { grayColor = SystemColors.Control; } this.moveUpImage = WixHelperMethods.MapBitmapColor(this.moveUpOriginalImage, Color.Black, SystemColors.ControlText); this.moveUpGrayImage = WixHelperMethods.MapBitmapColor(this.moveUpOriginalImage, Color.Black, grayColor); this.moveDownImage = WixHelperMethods.MapBitmapColor(this.moveDownOriginalImage, Color.Black, SystemColors.ControlText); this.moveDownGrayImage = WixHelperMethods.MapBitmapColor(this.moveDownOriginalImage, Color.Black, grayColor); this.deleteImage = WixHelperMethods.MapBitmapColor(this.deleteOriginalImage, Color.Black, SystemColors.ControlText); this.deleteGrayImage = WixHelperMethods.MapBitmapColor(this.deleteOriginalImage, Color.Black, grayColor); }
private void UpdateButton_Click(object sender, EventArgs e) { string folder = WixHelperMethods.EnsureTrailingDirectoryChar(this.folderTextBox.Text); int selectedIndex = this.pathsListBox.SelectedIndex; if (this.pathsListBox.SelectedItem.ToString() != folder) { CancelEventArgs ce = new CancelEventArgs(); this.OnFolderValidating(ce); if (!ce.Cancel) { this.pathsListBox.Items[selectedIndex] = folder; if (this.FoldersChanged != null) { this.FoldersChanged(this, new EventArgs()); } } } }
/// <summary> /// The environment calls this to get the parameters to describe the property page. /// </summary> /// <param name="pPageInfo">The parameters are returned in this one-sized array.</param> void IPropertyPage.GetPageInfo(PROPPAGEINFO[] pPageInfo) { WixHelperMethods.VerifyNonNullArgument(pPageInfo, "pPageInfo"); if (this.PropertyPagePanel == null) { this.PropertyPagePanel = this.CreatePropertyPagePanel(); } PROPPAGEINFO info = new PROPPAGEINFO(); info.cb = (uint)Marshal.SizeOf(typeof(PROPPAGEINFO)); info.dwHelpContext = 0; info.pszDocString = null; info.pszHelpFile = null; info.pszTitle = this.PageName; info.SIZE.cx = this.PropertyPagePanel.Width; info.SIZE.cy = this.PropertyPagePanel.Height; pPageInfo[0] = info; }
/// <summary> /// Called when a control is being validated. Set e.Cancel to true to cause the validation to fail. /// </summary> /// <param name="sender">The control being validated.</param> /// <param name="e">Parameters for the event.</param> private void HandleControlValidating(object sender, System.ComponentModel.CancelEventArgs e) { Control control = (Control)sender; string propertyName = (string)control.Tag; string value = control.Text; TextBox textBox = control as TextBox; if (textBox != null) { if (!textBox.Modified) { return; } value = this.ParentPropertyPage.Normalize(propertyName, value); } else { FoldersSelector foldesSelector = control as FoldersSelector; if (foldesSelector != null) { value = foldesSelector.TextBox.Text; } } string currentValue = this.ParentPropertyPage.GetProperty(propertyName); if (!String.Equals(value, currentValue, StringComparison.Ordinal)) { try { PropertyValidator.ValidateProperty(propertyName, value); } catch (ProjectPropertyArgumentException ex) { if (textBox != null) { // Don't retrigger Validation when losing focus due to the message box. textBox.Modified = false; } WixHelperMethods.ShowErrorMessageBox(this.ParentPropertyPage.Site, ex.Message); e.Cancel = true; if (textBox != null) { textBox.Text = currentValue; textBox.Modified = false; // Clear the page dirty flag if it was only this textbox that was modified. int isDirty; if (this.ParentPropertyPage.ProjectMgr.IsDirty(out isDirty) == 0 && isDirty == 0) { this.ParentPropertyPage.IsDirty = false; } } } } else if (textBox != null && textBox.Modified) { // The text wasn't significantly changed, but might need to be adjusted to the trimmed value. textBox.Text = value; textBox.Modified = false; // Clear the page dirty flag if it was only this textbox that was modified. int isDirty; if (this.ParentPropertyPage.ProjectMgr.IsDirty(out isDirty) == 0 && isDirty == 0) { this.ParentPropertyPage.IsDirty = false; } } }
/// <summary> /// Handles the help event by displaying the property pages help from WiX.chm. /// </summary> /// <param name="sender">The control sending the event.</param> /// <param name="hlpevent">Event parameters.</param> private void PropertyPagePanel_HelpRequested(object sender, HelpEventArgs hlpevent) { WixHelperMethods.ShowWixHelp(this.PropertyPagePanel, @"html\votive_property_pages.htm"); }
/// <summary> /// Sets a project property. /// </summary> /// <param name="propertyName">Name of the property to set.</param> /// <param name="value">Value of the property.</param> public override void SetProperty(string propertyName, string value) { if (propertyName == WixProjectFileConstants.DefineConstants) { ProjectProperty property = new ProjectProperty(this.ProjectMgr, WixProjectFileConstants.DefineConstants); foreach (ProjectConfig config in this.ProjectConfigs) { string existingConstantsString = property.GetValue(false, new ProjectConfig[] { config }); if (existingConstantsString == null) { existingConstantsString = String.Empty; } List <string> existingConstants = new List <string>(existingConstantsString.Split(';')); string constantsString = value.Trim(); List <string> constants = new List <string>(constantsString.Split(';')); if (WixHelperMethods.RemoveAllMatch(constants, DebugDefine) > 0 || existingConstants.Contains(DebugDefine)) { constants.Insert(0, DebugDefine); } constantsString = String.Join(";", constants.ToArray()); if (constantsString != existingConstantsString) { property.SetValue(constantsString, new ProjectConfig[] { config }); this.IsDirty = true; } } } else if (propertyName == WixProjectFileConstants.DefineDebugConstant) { ProjectProperty property = new ProjectProperty(this.ProjectMgr, WixProjectFileConstants.DefineConstants); foreach (ProjectConfig config in this.ProjectConfigs) { string existingConstantsString = property.GetValue(false, new ProjectConfig[] { config }); if (existingConstantsString == null) { existingConstantsString = String.Empty; } List <string> constants = new List <string>(existingConstantsString.Split(';')); WixHelperMethods.RemoveAllMatch(constants, DebugDefine); if (value == Boolean.TrueString) { constants.Insert(0, DebugDefine); } string constantsString = String.Join(";", constants.ToArray()); if (constantsString != existingConstantsString) { property.SetValue(constantsString, new ProjectConfig[] { config }); this.IsDirty = true; } } } else if (propertyName == WixProjectFileConstants.WarningLevel) { WixWarningLevel warningLevel = (WixWarningLevel)Int32.Parse(value, CultureInfo.InvariantCulture); if (warningLevel == WixWarningLevel.None) { base.SetProperty(WixProjectFileConstants.SuppressAllWarnings, Boolean.TrueString); base.SetProperty(WixProjectFileConstants.Pedantic, Boolean.FalseString); } else if (warningLevel == WixWarningLevel.Normal) { base.SetProperty(WixProjectFileConstants.SuppressAllWarnings, Boolean.FalseString); base.SetProperty(WixProjectFileConstants.Pedantic, Boolean.FalseString); } else if (warningLevel == WixWarningLevel.Pedantic) { base.SetProperty(WixProjectFileConstants.SuppressAllWarnings, Boolean.FalseString); base.SetProperty(WixProjectFileConstants.Pedantic, Boolean.TrueString); } } else { base.SetProperty(propertyName, value); } }
// ========================================================================================= // Methods // ========================================================================================= /// <summary> /// Adds a control to the collection of child controls /// </summary> /// <param name="value">Control to be added</param> public override void Add(Control value) { base.Add(value); WixHelperMethods.SetControlTreeColors(value); }