using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using VEPROMS.CSLA.Library; using VEPROMS.Properties; using DevComponents.DotNetBar; namespace VEPROMS { public partial class frmSectionProperties : DevComponents.DotNetBar.Office2007Form { private string _DefaultFormatName = null; private bool _Initializing; private SectionConfig _SectionConfig; public frmSectionProperties(SectionConfig sectionConfig) { _SectionConfig = sectionConfig; InitializeComponent(); btnGeneral.PerformClick(); // always start with General tab or button if (sectionConfig.Number.Length > 0) this.Text = string.Format("{0} {1} Properties", sectionConfig.Number, sectionConfig.Title); else this.Text = string.Format("{0} Properties", sectionConfig.Title); } private void btnFlderPropOK_Click(object sender, EventArgs e) { sectionConfigBindingSource.EndEdit(); // Save Default settings for User // // Save whether we should display the default values on this property page Settings.Default.ShowDefaultSectionProp = ppCbShwDefSettings.Checked; Settings.Default.Save(); DialogResult = DialogResult.OK; this.Close(); } private void btnFldrPropCancel_Click(object sender, EventArgs e) { sectionConfigBindingSource.CancelEdit(); this.Close(); } /// /// Use the ParentLookup to grab the default values /// - set the watermark property (where applicable) of the control with that value /// - set the default setting labels with that value /// ** the default setting labels appear when the Show Default Values checkbox is checked by the user. /// private void FindDefaultValues() { _SectionConfig.ParentLookup = true; // Get the default format name _DefaultFormatName = _SectionConfig.DefaultFormatSelection; if (_DefaultFormatName != null && !(_DefaultFormatName.Equals(""))) { ppLblFormatDefault.Text = string.Format("({0})", _DefaultFormatName); ppCmbxFormat.WatermarkText = string.Format("{0}", _DefaultFormatName); } _SectionConfig.ParentLookup = false; } private void frmSectionProperties_Load(object sender, EventArgs e) { _Initializing = true; sectionConfigBindingSource.DataSource = _SectionConfig; formatInfoListBindingSource.DataSource = FormatInfoList.Get(); // Get the saved settings for this user // // Get setting telling us whether to display the default values on this property page ppCbShwDefSettings.Checked = (Settings.Default["ShowDefaultSectionProp"] != null) ? Settings.Default.ShowDefaultSectionProp : false; // Get the User's property page style "PropPageStyle" (this is a system wide user setting) // 1 - Button Dialog (default) // 2 - Tab Dialog if ((int)Settings.Default["PropPageStyle"] == (int)PropPgStyle.Tab) { tcSectionProp.TabsVisible = true; panSectBtns.Visible = false; this.Width -= panSectBtns.Width; } // Get the default values for the property page information FindDefaultValues(); ppCmbxSectPagination.DataSource = EnumDetail.Details(); ppCmbxSectPagination.DisplayMember = "Description"; ppCmbxSectPagination.ValueMember = "EValue"; ppCmbxNumColumns.DataSource = EnumDetail.Details(); ppCmbxNumColumns.DisplayMember = "Description"; ppCmbxNumColumns.ValueMember = "EValue"; _Initializing = false; } #region General tab /// /// This is the General button used on the button interface design /// /// object /// EventArgs private void btnGeneral_Click(object sender, EventArgs e) { ProcessButtonClick(tiGeneral, btnGeneral); } #endregion #region Format tab /// /// This is the Format button used on the button interface design /// /// object /// EventArgs private void btnFormat_Click(object sender, EventArgs e) { ProcessButtonClick(tiFormat, btnFormat); } /// /// Selection in Format combo box changed. /// /// object /// EventArgs private void ppCmbxFormat_SelectedValueChanged(object sender, EventArgs e) { if ((ppCmbxFormat.SelectedIndex != -1) && _DefaultFormatName.Equals(ppCmbxFormat.SelectedValue)) { ppBtnDefaultFmt.Focus(); ppBtnDefaultFmt.PerformClick(); } ppBtnDefaultFmt.Visible = (ppCmbxFormat.SelectedValue != null); ppLblFormatDefault.Visible = ppCbShwDefSettings.Checked && ppBtnDefaultFmt.Visible; } private void ppBtnDefaultFmt_Click(object sender, EventArgs e) { ppCmbxFormat.SelectedIndex = -1; //reset to the default Format setting } #endregion #region Library Document tab /// /// This is the Library Document button used on the button interface design /// /// object /// EventArgs private void btnLibDocs_Click(object sender, EventArgs e) { ProcessButtonClick(tiLibDoc, btnLibDocs); } #endregion #region View Settings tab /// /// This is the View Settings button used on the button interface design /// /// object /// EventArgs private void btnViewStngs_Click(object sender, EventArgs e) { ProcessButtonClick(tiViewStnns, btnViewStngs); } #endregion #region Generic functions used on this property page /// /// Determines what labels (showing default values) are visable on the property pages /// private void defaultSettingsVisiblity() { ppLblDefSettingsInfo.Visible = ppCbShwDefSettings.Checked; ppLblFormatDefault.Visible = ppCbShwDefSettings.Checked && ppBtnDefaultFmt.Visible; } /// /// For the Button Interface property page style, when a button is selected (pressed), /// it will remain in the checked state even when a different button is selected. Thus /// we must clear the checked state of the buttons when a button is selected, then set /// the newly selected button's state to checked. /// private void ClearAllCheckedButtons() { btnGeneral.Checked = false; btnFormat.Checked = false; btnLibDocs.Checked = false; btnViewStngs.Checked = false; } /// /// Select the corresponding tab and set the button's state to checked /// /// Property Page Tab /// Corresponding Property Page Button private void ProcessButtonClick(TabItem tab, ButtonX button) { ClearAllCheckedButtons(); tcSectionProp.SelectedTab = tab; button.Checked = true; } /// /// This is a generic Enter Event function for use with all of the property page tabs. /// Found that the visiblity value of buttons is not recorded until the property page in which it resides is diplayed. /// Thus we need to call defaultSettingVisiblity() to check and set visiblity states. /// /// type object /// type EventArgs private void tabpage_Enter(object sender, EventArgs e) { // Show or hide the labels containing the default values if (!_Initializing) defaultSettingsVisiblity(); } #endregion } }