コード例 #1
0
        public void GetValueTest()
        {
            FormSettingsCD target   = new FormSettingsCD(); // TODO: Initialize to an appropriate value
            string         key      = string.Empty;         // TODO: Initialize to an appropriate value
            string         expected = string.Empty;         // TODO: Initialize to an appropriate value
            string         actual;

            actual = target.GetValue(key);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
コード例 #2
0
        /// <summary>
        /// A Window that allows the Editing of FormSettings
        /// </summary>
        public FormSettingsUi(FormSettingsCD formSettings)
        {
            InitializeComponent();

            _cboAltColor1.LoadColors(ColorSet.Web);

            if (formSettings != null)
            {
                _formSettings = formSettings;
            }

            var altColor1 = _formSettings.GetValue("AltColor1");

            if (altColor1 != null)
            {
                _cboAltColor1.SelectedColor = Color.FromName(altColor1);
            }
        }
コード例 #3
0
        /// <summary>
        /// Format the Grid's AlternatingRowsBackColor and Column properties (HeaderText, Visible, DisplayIndex, Width, Alignment, Format)
        /// </summary>
        public void GridSettings_Apply()
        {
            try
            {
                if (_formSettings.GetValue("AltColor1") == null)
                {
                    _formSettings.SetValue("AltColor1", "AliceBlue");
                }
                Banner.BackColor = Color.FromName(_formSettings.GetValue("AltColor1"));
                DataGridView.AlternatingRowsDefaultCellStyle.BackColor = Color.FromName(_formSettings.GetValue("AltColor1"));

                int i;

                #region Set column properties (Visible, DisplayIndex, Width) from GridSettings
                _gridSettings.ClientGetGridSettings(SystemInformation.UserName, GridName, false);
                var count = _gridSettings.GridSettings.Count;

                for (i = 0; i < count; i++)
                {
                    var columnName = _gridSettings.GridSettings[i].ColumnName;
                    // ReSharper disable PossibleNullReferenceException
                    DataGridView.Columns[columnName].AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
                    DataGridView.Columns[columnName].Visible      = _gridSettings.GridSettings[i].Visible;
                    DataGridView.Columns[columnName].DisplayIndex = _gridSettings.GridSettings[i].DisplayIndex;
                    DataGridView.Columns[columnName].Width        = _gridSettings.GridSettings[i].Width;
                    // ReSharper restore PossibleNullReferenceException
                }
                #endregion

                DataGridView.RowsDefaultCellStyle.WrapMode = DataGridViewTriState.True;
                #region auto Set column properties (Alignment, Format) based on DataType
                var dataSource = (DataTable)BindingSource.DataSource;
                for (i = 0; i < dataSource.Columns.Count; i++)
                {
                    DataGridView.Columns[i].HeaderText = dataSource.Columns[i].Caption;

                    switch (dataSource.Columns[i].DataType.ToString())
                    {
                    case "System.Boolean":
                        DataGridView.Columns[i].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
                        break;

                    case "System.DateTime":
                        DataGridView.Columns[i].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
                        DataGridView.Columns[i].DefaultCellStyle.Format    = "MM/dd/yyyy";
                        break;

                    case "System.Decimal":
                    case "System.Double":
                    case "System.Single":
                        DataGridView.Columns[i].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                        DataGridView.Columns[i].DefaultCellStyle.Format    = "#,#.##";
                        break;

                    case "System.Int16":
                    case "System.Int32":
                    case "System.Int64":
                    case "System.UInt16":
                    case "System.UInt32":
                    case "System.UInt64":
                    case "System.Byte":
                    case "System.SByte":
                        DataGridView.Columns[i].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                        DataGridView.Columns[i].DefaultCellStyle.Format    = "#,0";
                        break;

                    default:                             //Char, String
                        DataGridView.Columns[i].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
                        break;
                    }
                }
                #endregion

                #region Set Sort from Previous
                Sort_LoadColumns();

                var sortCol1 = _formSettings.GetValue("SortCol1");
                var sortSrt1 = _formSettings.GetValue("SortSrt1");
                var sortCol2 = _formSettings.GetValue("SortCol2");
                var sortSrt2 = _formSettings.GetValue("SortSrt2");
                var sortCol3 = _formSettings.GetValue("SortCol3");
                var sortSrt3 = _formSettings.GetValue("SortSrt3");

                _cboSortCol1.SelectedIndex = 0;
                _cboSortSrt1.SelectedIndex = 0;
                _cboSortCol2.SelectedIndex = 0;
                _cboSortSrt2.SelectedIndex = 0;
                _cboSortCol3.SelectedIndex = 0;
                _cboSortSrt3.SelectedIndex = 0;

                if (!string.IsNullOrEmpty(sortCol1) && _cboSortCol1.FindStringExact(sortCol1) > 0)
                {
                    _cboSortCol1.Text = sortCol1;
                    if (!string.IsNullOrEmpty(sortSrt1))
                    {
                        if (_cboSortSrt1.FindStringExact(sortSrt1) >= 0)
                        {
                            _cboSortSrt1.Text = sortSrt1;
                        }
                    }

                    if (!string.IsNullOrEmpty(sortCol2) && _cboSortCol2.FindStringExact(sortCol2) > 0)
                    {
                        _cboSortCol2.Text = sortCol2;
                        if (!string.IsNullOrEmpty(sortSrt2))
                        {
                            if (_cboSortSrt2.FindStringExact(sortSrt2) >= 0)
                            {
                                _cboSortSrt2.Text = sortSrt2;
                            }
                        }

                        if (!string.IsNullOrEmpty(sortCol3) && _cboSortCol3.FindStringExact(sortCol3) > 0)
                        {
                            _cboSortCol3.Text = _formSettings.GetValue("SortCol3");
                            if (!string.IsNullOrEmpty(sortSrt3))
                            {
                                if (_cboSortSrt3.FindStringExact(sortSrt3) >= 0)
                                {
                                    _cboSortSrt3.Text = sortSrt3;
                                }
                            }
                        }
                    }
                    _btnSortApply_Click(null, null);
                }
                #endregion

                #region Set Filter from Previous
                Filter_LoadSettings();

                if (!string.IsNullOrEmpty(_formSettings.GetValue("FilterDS")))
                {
                    var ds = new DataSet("FilterDS");
                    ds.ReadXml(new StringReader(_formSettings.GetValue("FilterDS")));
                    _filterEditor.SetFilterDataGridView(ds);
                    if (_filterEditor.Filter != null)
                    {
                        _txtFilter.Text = _filterEditor.Filter;
                        _btnFilterApply_Click(null, null);
                    }
                }
                #endregion
            }
            catch { }
        }