private void AddPropertyToPropertiesGrid(ArchAngel.Providers.EntityModel.Model.EntityLayer.Property property, bool hasMultiSchemas)
        {
            SlyceTreeGridItem gridItem = new SlyceTreeGridItem();
            gridItem.Tag = property;
            gridItem.SubItems.Add(new SlyceTreeGridCellItem(property.Name));
            gridItem.SubItems.Add(new SlyceTreeGridCellItem(property.Type));
            gridItem.SubItems.Add(new SlyceTreeGridCellItem(property.NHibernateType));

            int numTables = MappedTables.Count;
            IColumn mappedColumn = property.MappedColumn();
            string mappedColumnName;

            if (mappedColumn == null)
                mappedColumnName = "";
            else if (numTables == 1)
                mappedColumnName = mappedColumn.Name;
            else if (hasMultiSchemas)
                mappedColumnName = string.Format("{0}.{1}.{2}", mappedColumn.Parent.Schema, mappedColumn.Parent.Name, mappedColumn.Name);
            else
                mappedColumnName = string.Format("{0}.{1}", mappedColumn.Parent.Name, mappedColumn.Name);

            gridItem.SubItems.Add(new SlyceTreeGridCellItem(mappedColumnName));
            gridItem.SubItems.Add(new SlyceTreeGridCellItem(property.IsKeyProperty));
            gridItem.SubItems.Add(new SlyceTreeGridCellItem(property.ReadOnly));

            foreach (ArchAngel.Interfaces.ITemplate.IUserOption uo in property.Ex.OrderBy(u => u.Name))
            {
                if (uo.DataType == typeof(bool?))
                {
                    bool? nullableBoolValue = (bool?)uo.Value;
                    gridItem.SubItems.Add(new SlyceTreeGridCellItem(false, true, nullableBoolValue.HasValue ? nullableBoolValue.Value : false));
                }
                else if (uo.DataType == typeof(string))
                    gridItem.SubItems.Add(new SlyceTreeGridCellItem((string)uo.Value));
                else if (uo.DataType == typeof(int))
                    gridItem.SubItems.Add(new SlyceTreeGridCellItem((int)uo.Value));
                else if (uo.DataType == typeof(bool))
                    gridItem.SubItems.Add(new SlyceTreeGridCellItem((bool)uo.Value));
                else if (uo.DataType.ToString() == "ArchAngel.Interfaces.NHibernateEnums.PropertyAccessTypes")
                    gridItem.SubItems.Add(new SlyceTreeGridCellItem(uo.Value.ToString()));
                else if (uo.DataType.ToString() == "ArchAngel.Interfaces.NHibernateEnums.PropertyGeneratedTypes")
                    gridItem.SubItems.Add(new SlyceTreeGridCellItem(uo.Value.ToString()));
                else
                    throw new NotImplementedException("Type not handled yet: " + uo.DataType.Name);
            }
            gridItem.SubItems.Add(CreateNewNullableCell(property, property.ValidationOptions.FractionalDigits, ApplicableOptions.Digits));
            gridItem.SubItems.Add(CreateNewNullableCell(property, property.ValidationOptions.FutureDate, ApplicableOptions.Date));
            gridItem.SubItems.Add(CreateNewNullableCell(property, property.ValidationOptions.IntegerDigits, ApplicableOptions.Digits));
            gridItem.SubItems.Add(CreateNewNullableCell(property, property.ValidationOptions.MaximumLength, ApplicableOptions.Length));
            gridItem.SubItems.Add(CreateNewNullableCell(property, property.ValidationOptions.MinimumLength, ApplicableOptions.Length));
            gridItem.SubItems.Add(CreateNewNullableCell(property, property.ValidationOptions.MaximumValue, ApplicableOptions.Value));
            gridItem.SubItems.Add(CreateNewNullableCell(property, property.ValidationOptions.MinimumValue, ApplicableOptions.Value));
            gridItem.SubItems.Add(CreateNewNullableCell(property, property.ValidationOptions.NotEmpty, ApplicableOptions.NotEmpty));
            gridItem.SubItems.Add(CreateNewNullableCell(property, property.ValidationOptions.Nullable, ApplicableOptions.Nullable));
            gridItem.SubItems.Add(CreateNewNullableCell(property, property.ValidationOptions.PastDate, ApplicableOptions.Date));
            gridItem.SubItems.Add(CreateNewNullableCell(property, property.ValidationOptions.RegexPattern, ApplicableOptions.RegexPattern));
            gridItem.SubItems.Add(new SlyceTreeGridCellItem(property.ValidationOptions.Validate, (ValidationOptions.GetApplicableValidationOptionsForType(property.Type) & ApplicableOptions.Validate) != ApplicableOptions.Validate));

            slyceGrid1.Items.Add(gridItem);
        }
Пример #2
0
 private void AddKeyToKeysGrid(Key key)
 {
     SlyceTreeGridItem gridItem = new SlyceTreeGridItem();
     gridItem.Tag = key;
     gridItem.SubItems.Add(new SlyceTreeGridCellItem(key.Name));
     gridItem.SubItems.Add(new SlyceTreeGridCellItem(key.Keytype.ToString()));
     gridItem.SubItems.Add(new SlyceTreeGridCellItem(key.Description));
     slyceGrid1.Items.Add(gridItem);
 }
        private void AddPropertyToPropertiesGrid(ComponentPropertyImpl property)
        {
            SlyceTreeGridItem gridItem = new SlyceTreeGridItem();
            gridItem.Tag = property;
            gridItem.SubItems.Add(new SlyceTreeGridCellItem(property.Name));
            gridItem.SubItems.Add(new SlyceTreeGridCellItem(property.Type));

            foreach (ArchAngel.Interfaces.ITemplate.IUserOption uo in property.Ex)
            {
                if (uo.DataType == typeof(bool?))
                {
                    bool? nullableBoolValue = (bool?)uo.Value;
                    gridItem.SubItems.Add(new SlyceTreeGridCellItem(false, true, nullableBoolValue.HasValue ? nullableBoolValue.Value : false));
                }
                else if (uo.DataType == typeof(string))
                {
                    gridItem.SubItems.Add(new SlyceTreeGridCellItem((string)uo.Value));
                }
                else if (uo.DataType == typeof(int))
                {
                    gridItem.SubItems.Add(new SlyceTreeGridCellItem((int)uo.Value));
                }
                else if (uo.DataType == typeof(bool))
                {
                    gridItem.SubItems.Add(new SlyceTreeGridCellItem((bool)uo.Value));
                }
                else
                {
                    throw new NotImplementedException("Type not handled yet: " + uo.DataType.Name);
                }
            }
            gridItem.SubItems.Add(CreateNewNullableCell(property, property.ValidationOptions.FractionalDigits, ApplicableOptions.Digits));
            gridItem.SubItems.Add(CreateNewNullableCell(property, property.ValidationOptions.FutureDate, ApplicableOptions.Date));
            gridItem.SubItems.Add(CreateNewNullableCell(property, property.ValidationOptions.IntegerDigits, ApplicableOptions.Digits));
            gridItem.SubItems.Add(CreateNewNullableCell(property, property.ValidationOptions.MaximumLength, ApplicableOptions.Length));
            gridItem.SubItems.Add(CreateNewNullableCell(property, property.ValidationOptions.MinimumLength, ApplicableOptions.Length));
            gridItem.SubItems.Add(CreateNewNullableCell(property, property.ValidationOptions.MaximumValue, ApplicableOptions.Value));
            gridItem.SubItems.Add(CreateNewNullableCell(property, property.ValidationOptions.MinimumValue, ApplicableOptions.Value));
            gridItem.SubItems.Add(CreateNewNullableCell(property, property.ValidationOptions.NotEmpty, ApplicableOptions.NotEmpty));
            gridItem.SubItems.Add(CreateNewNullableCell(property, property.ValidationOptions.Nullable, ApplicableOptions.Nullable));
            gridItem.SubItems.Add(CreateNewNullableCell(property, property.ValidationOptions.PastDate, ApplicableOptions.Date));
            gridItem.SubItems.Add(CreateNewNullableCell(property, property.ValidationOptions.RegexPattern, ApplicableOptions.RegexPattern));
            gridItem.SubItems.Add(new SlyceTreeGridCellItem(property.ValidationOptions.Validate, (ValidationOptions.GetApplicableValidationOptionsForType(property.Type) & ApplicableOptions.Validate) != ApplicableOptions.Validate));

            slyceGrid1.Items.Add(gridItem);
        }
Пример #4
0
        public void Populate()
        {
            try
            {
                BusyPopulating = true;
                ResetLabelCache();
                Slyce.Common.Utility.SuspendPainting(dataGridViewX1);
                dataGridViewX1.Rows.Clear();

                PopulateColumns();

                for (int i = 0; i < Items.Count; i++)
                {
                    SlyceTreeGridItem item = Items[i];
                    AddItemToGrid(item, false);
                }
                //RefreshHeaderLabels();

                if (dataGridViewX1.Rows.Count > 0)
                {
                    if (ShowDeleteColumn)
                    {
                        dataGridViewX1.Rows[0].Cells[1].Selected = true;
                    }
                    else
                    {
                        dataGridViewX1.Rows[0].Cells[0].Selected = true;
                    }
                }
                ResetAllDeleteImages();
            }
            finally
            {
                Slyce.Common.Utility.ResumePainting(dataGridViewX1);
                BusyPopulating = false;
                dataGridViewX1.Refresh();
                ResetLabelCache();
                RefreshHeaderLabels();
            }
        }
Пример #5
0
        private void AddColumnToColumnsGrid(Column column)
        {
            SlyceTreeGridItem gridItem = new SlyceTreeGridItem();
            gridItem.Tag = column;
            gridItem.SubItems.Add(new SlyceTreeGridCellItem(column.Name));
            gridItem.SubItems.Add(new SlyceTreeGridCellItem(column.Description));
            gridItem.SubItems.Add(new SlyceTreeGridCellItem(column.IsNullable));
            gridItem.SubItems.Add(new SlyceTreeGridCellItem(column.OriginalDataType == null ? null : column.OriginalDataType.ToLower()));
            gridItem.SubItems.Add(new SlyceTreeGridCellItem(column.Default));
            gridItem.SubItems.Add(new SlyceTreeGridCellItem(column.OrdinalPosition));
            gridItem.SubItems.Add(new SlyceTreeGridCellItem(column.Size));
            gridItem.SubItems.Add(new SlyceTreeGridCellItem(column.SizeIsMax));
            gridItem.SubItems.Add(new SlyceTreeGridCellItem(column.Precision));
            gridItem.SubItems.Add(new SlyceTreeGridCellItem(column.Scale));

            foreach (IKey key in Table.Keys)
            {
                SlyceTreeGridCellItem item = new SlyceTreeGridCellItem(key.Columns.Contains(column));
                item.Enabled = true;// column.InPrimaryKey;
                gridItem.SubItems.Add(item);
            }

            slyceGrid1.Items.Add(gridItem);
        }
Пример #6
0
        private void AddItemToGrid(SlyceTreeGridItem item, bool updateLastRow)
        {
            List<object> subItemValues = new List<object>();

            if (ShowDeleteColumn)
                subItemValues.Add(DeleteImage);

            List<int> cellsToIgnore = new List<int>();
            List<int> cellsToDisable = new List<int>();

            for (int subItemCounter = 0; subItemCounter < item.SubItems.Count; subItemCounter++)
            {
                SlyceTreeGridCellItem subItem = item.SubItems[subItemCounter];

                //if (subItem.IsNullable)
                //{
                //    subItemValues.Add(subItem.HasValue);

                //    if (subItem.Ignore)
                //        cellsToIgnore.Add(subItemValues.Count - 1);
                //}
                subItemValues.Add(subItem.Value);

                if (subItem.Ignore)
                    cellsToIgnore.Add(subItemValues.Count - 1);

                if (!subItem.Enabled)
                    cellsToDisable.Add(subItemValues.Count - 1);

                //else if (subItem.IsNullable && !subItem.HasValue)
                //    cellsToDisable.Add(subItemValues.Count - 1);
            }
            int i;

            if (updateLastRow)
            {
                i = dataGridViewX1.Rows.Count - 2;
                dataGridViewX1.Rows[i].SetValues(subItemValues.ToArray());
            }
            else
                i = dataGridViewX1.Rows.Add(subItemValues.ToArray());

            foreach (int cellIndex in cellsToIgnore)
            {
                if (cellIndex >= dataGridViewX1.Rows[i].Cells.Count)
                    continue;

                object ccc = dataGridViewX1.Rows[i].Cells[cellIndex];

                if (ccc is DataGridViewTextBoxCellEx)
                    ((DataGridViewTextBoxCellEx)ccc).Enabled = false;
                else if (ccc is DataGridViewComboBoxCellEx)
                    ((DataGridViewComboBoxCellEx)ccc).Enabled = false;
                else
                {
                    dataGridViewX1.Rows[i].Cells[cellIndex].ReadOnly = true;
                    dataGridViewX1.Rows[i].Cells[cellIndex].Style.BackColor = Color.Pink;
                    //dataGridViewX1.Rows[i].Cells[cellIndex - 1].Style.BackColor = Color.Pink;
                }
            }
            foreach (int cellIndex in cellsToDisable)
            {
                dataGridViewX1.Rows[i].Cells[cellIndex].ReadOnly = true;
                //dataGridViewX1.Rows[i].Cells[cellIndex].Style.BackColor = Color.LightGray;
                //dataGridViewX1.Rows[i].Cells[cellIndex - 1].Style.BackColor = Color.LightGray;
            }
            for (int rowCounter = 0; rowCounter < dataGridViewX1.Rows.Count; rowCounter++)
                dataGridViewX1.Rows[rowCounter].DefaultCellStyle.BackColor = rowCounter % 2 == 0 ? BackColor : AlternatingBackColor;

            Tags.Add(item.Tag);
        }
Пример #7
0
        private void AddEntityToEntitiesGrid(Entity entity)
        {
            SlyceTreeGridItem gridItem = new SlyceTreeGridItem();
            gridItem.Tag = entity;
            gridItem.SubItems.Add(new SlyceTreeGridCellItem(entity.Name));

            #region Namespaces
            if (ShowNamespaces)
            {
                bool exists = false;

                foreach (CustomNamespace ns in EntitySet.CustomNamespaces.OrderBy(n => n.Value))
                {
                    exists = true;
                    bool isChecked = ns.Entities.Contains(entity);
                    gridItem.SubItems.Add(new SlyceTreeGridCellItem(isChecked));
                }
                if (!exists)
                    gridItem.SubItems.Add(new SlyceTreeGridCellItem(null));
            }
            #endregion

            #region Attributes
            if (ShowAttributes)
            {
                bool exists = false;

                foreach (CustomAttribute ca in EntitySet.CustomAttributes.OrderBy(n => n.RawName))
                {
                    exists = true;
                    bool isChecked = ca.Entities.Contains(entity);
                    gridItem.SubItems.Add(new SlyceTreeGridCellItem(isChecked));
                }
                if (!exists)
                    gridItem.SubItems.Add(new SlyceTreeGridCellItem(null));
            }
            #endregion

            #region Implements
            if (ShowImplements)
            {
                bool exists = false;

                foreach (CustomImplement ci in EntitySet.CustomImplements.OrderBy(n => n.Value))
                {
                    exists = true;
                    bool isChecked = ci.Entities.Contains(entity);
                    gridItem.SubItems.Add(new SlyceTreeGridCellItem(isChecked));
                }
                if (!exists)
                    gridItem.SubItems.Add(new SlyceTreeGridCellItem(null));
            }
            #endregion

            #region Properties
            if (ShowProperties)
            {
                bool exists = false;

                foreach (CustomProperty cp in EntitySet.CustomProperties.OrderBy(n => n.Name))
                {
                    exists = true;
                    bool isChecked = cp.Entities.Contains(entity);
                    gridItem.SubItems.Add(new SlyceTreeGridCellItem(isChecked));
                }
                if (!exists)
                    gridItem.SubItems.Add(new SlyceTreeGridCellItem(null));
            }
            #endregion

            #region Functions
            if (ShowFunctions)
            {
                bool exists = false;

                foreach (CustomFunction cm in EntitySet.CustomFunctions.OrderBy(n => n.Name))
                {
                    exists = true;
                    bool isChecked = cm.Entities.Contains(entity);
                    gridItem.SubItems.Add(new SlyceTreeGridCellItem(isChecked));
                }
                if (!exists)
                    gridItem.SubItems.Add(new SlyceTreeGridCellItem(null));
            }
            #endregion

            slyceGridEntities.Items.Add(gridItem);
        }
Пример #8
0
        private void AddItemToGrid(SlyceTreeGridItem item, bool updateLastRow)
        {
            List <object> subItemValues = new List <object>();

            if (ShowDeleteColumn)
            {
                subItemValues.Add(DeleteImage);
            }

            List <int> cellsToIgnore  = new List <int>();
            List <int> cellsToDisable = new List <int>();

            for (int subItemCounter = 0; subItemCounter < item.SubItems.Count; subItemCounter++)
            {
                SlyceTreeGridCellItem subItem = item.SubItems[subItemCounter];

                //if (subItem.IsNullable)
                //{
                //    subItemValues.Add(subItem.HasValue);

                //    if (subItem.Ignore)
                //        cellsToIgnore.Add(subItemValues.Count - 1);
                //}
                subItemValues.Add(subItem.Value);

                if (subItem.Ignore)
                {
                    cellsToIgnore.Add(subItemValues.Count - 1);
                }

                if (!subItem.Enabled)
                {
                    cellsToDisable.Add(subItemValues.Count - 1);
                }

                //else if (subItem.IsNullable && !subItem.HasValue)
                //    cellsToDisable.Add(subItemValues.Count - 1);
            }
            int i;

            if (updateLastRow)
            {
                i = dataGridViewX1.Rows.Count - 2;
                dataGridViewX1.Rows[i].SetValues(subItemValues.ToArray());
            }
            else
            {
                i = dataGridViewX1.Rows.Add(subItemValues.ToArray());
            }

            foreach (int cellIndex in cellsToIgnore)
            {
                if (cellIndex >= dataGridViewX1.Rows[i].Cells.Count)
                {
                    continue;
                }

                object ccc = dataGridViewX1.Rows[i].Cells[cellIndex];

                if (ccc is DataGridViewTextBoxCellEx)
                {
                    ((DataGridViewTextBoxCellEx)ccc).Enabled = false;
                }
                else if (ccc is DataGridViewComboBoxCellEx)
                {
                    ((DataGridViewComboBoxCellEx)ccc).Enabled = false;
                }
                else
                {
                    dataGridViewX1.Rows[i].Cells[cellIndex].ReadOnly        = true;
                    dataGridViewX1.Rows[i].Cells[cellIndex].Style.BackColor = Color.Pink;
                    //dataGridViewX1.Rows[i].Cells[cellIndex - 1].Style.BackColor = Color.Pink;
                }
            }
            foreach (int cellIndex in cellsToDisable)
            {
                dataGridViewX1.Rows[i].Cells[cellIndex].ReadOnly = true;
                //dataGridViewX1.Rows[i].Cells[cellIndex].Style.BackColor = Color.LightGray;
                //dataGridViewX1.Rows[i].Cells[cellIndex - 1].Style.BackColor = Color.LightGray;
            }
            for (int rowCounter = 0; rowCounter < dataGridViewX1.Rows.Count; rowCounter++)
            {
                dataGridViewX1.Rows[rowCounter].DefaultCellStyle.BackColor = rowCounter % 2 == 0 ? BackColor : AlternatingBackColor;
            }

            Tags.Add(item.Tag);
        }