Exemplo n.º 1
0
        static SubSession()
        {
            MyFlagProperty = DataPropertyDescriptor <bool> .Register("MyFlag", typeof(SubSession));

            DoSubActionOperation      = OperationDescriptor.Register("DoSubAction", typeof(SubSession));
            DoOtherSubActionOperation = OperationDescriptor.Register("DoOtherSubAction", typeof(SubSession));
            OnStaticConstruction();
        }
Exemplo n.º 2
0
 public void SetPropertyDescriptor(DataSchema dataSchema, DataPropertyDescriptor propertyDescriptor)
 {
     DataSchema         = dataSchema;
     PropertyDescriptor = propertyDescriptor;
     PopulateCombo(comboOperation1, FilterOperations.OP_HAS_ANY_VALUE.DisplayName, dataSchema, propertyDescriptor.PropertyType);
     PopulateCombo(comboOperation2, Resources.QuickFilterForm_SetPropertyDescriptor_No_other_filter, dataSchema, propertyDescriptor.PropertyType);
     Text = string.Format(Resources.QuickFilterForm_SetPropertyDescriptor_Show_rows_where__0____, propertyDescriptor.DisplayName);
 }
Exemplo n.º 3
0
 public static ColumnRef FromPropertyDescriptor(DataPropertyDescriptor dataPropertyDescriptor)
 {
     if (dataPropertyDescriptor is ColumnPropertyDescriptor columnPropertyDescriptor)
     {
         return(new ColumnRef(columnPropertyDescriptor.PropertyPath));
     }
     return(new ColumnRef(new ColumnId(dataPropertyDescriptor.ColumnCaption)));
 }
Exemplo n.º 4
0
        public Color?GetColumnColor(DataPropertyDescriptor propertyDescriptor)
        {
            if (_columnColors.TryGetValue(propertyDescriptor.Name, out Color color))
            {
                return(color);
            }

            return(null);
        }
Exemplo n.º 5
0
        public Color?GetColor(DataPropertyDescriptor propertyDescriptor, RowItem rowItem)
        {
            if (!_colorManagers.TryGetValue(propertyDescriptor.Name, out ColorManager colorManager))
            {
                return(null);
            }

            return(colorManager.ColorScheme.GetColor(colorManager.GetRowValue(rowItem, propertyDescriptor)));
        }
Exemplo n.º 6
0
        protected virtual void boundDataGridView_CellContextMenuStripNeeded(object sender, DataGridViewCellContextMenuStripNeededEventArgs e)
        {
            DataPropertyDescriptor propertyDescriptor = null;

            if (e.ColumnIndex >= 0)
            {
                var column = boundDataGridView.Columns[e.ColumnIndex];
                propertyDescriptor = GetPropertyDescriptor(column);
            }
            e.ContextMenuStrip = contextMenuStrip;
            _columnFilterPropertyDescriptor = propertyDescriptor;
            UpdateContextMenuItems();
        }
Exemplo n.º 7
0
        public Predicate <object> GetPredicate(DataSchema dataSchema, DataPropertyDescriptor propertyDescriptor)
        {
            var columnFilters = GetColumnFilters(propertyDescriptor).ToArray();

            if (columnFilters.Length == 0)
            {
                return(null);
            }
            var predicates = columnFilters
                             .Select(filter => filter.Predicate.MakePredicate(dataSchema, propertyDescriptor.PropertyType))
                             .ToArray();

            return(value => predicates.All(predicate => predicate(value)));
        }
        static MainSession()
        {
            SampleFlagProperty = DataPropertyDescriptor <bool> .Register("SampleFlag", typeof(MainSession));

            IsLoggedInProperty = DataPropertyDescriptor <bool> .Register("IsLoggedIn", typeof(MainSession));

            SubSessionProperty = SessionPropertyDescriptor <SubSession> .Register("SubSession", typeof(MainSession));

            LoginSessionProperty = SessionPropertyDescriptor <LoginSession> .Register("LoginSession", typeof(MainSession));

            DoActionOperation      = OperationDescriptor.Register("DoAction", typeof(MainSession));
            DoOtherActionOperation = OperationDescriptor.Register("DoOtherAction", typeof(MainSession));
            LogOutOperation        = OperationDescriptor.Register("LogOut", typeof(MainSession));
            OnStaticConstruction();
        }
Exemplo n.º 9
0
            public object GetRowValue(RowItem rowItem, DataPropertyDescriptor propertyDescriptor)
            {
                if (Transform == null)
                {
                    return(propertyDescriptor.GetValue(rowItem));
                }
                var pdIndex = PropertyDescriptors.IndexOf(propertyDescriptor);

                if (pdIndex < 0)
                {
                    return(null);
                }

                return(GetRowValues(rowItem).Skip(pdIndex).FirstOrDefault());
            }
Exemplo n.º 10
0
        public void SetFilter(DataSchema dataSchema, DataPropertyDescriptor propertyDescriptor, RowFilter rowFilter)
        {
            RowFilter = rowFilter;
            SetPropertyDescriptor(dataSchema, propertyDescriptor);
            var columnFilters = rowFilter.GetColumnFilters(propertyDescriptor).ToArray();

            if (columnFilters.Length >= 1)
            {
                SetFilterOperation(comboOperation1, tbxOperand1, columnFilters[0]);
                tbxOperand1.Text = columnFilters[0].Predicate.GetOperandDisplayText(dataSchema, propertyDescriptor.PropertyType);
            }
            if (columnFilters.Length >= 2)
            {
                SetFilterOperation(comboOperation2, tbxOperand2, columnFilters[1]);
            }
        }
        static LoginSession()
        {
            UserNameProperty = DataPropertyDescriptor <string> .Register("UserName", typeof(LoginSession));

            PasswordProperty = DataPropertyDescriptor <string> .Register("Password", typeof(LoginSession));

            NewUserNameProperty = DataPropertyDescriptor <string> .Register("NewUserName", typeof(LoginSession));

            NewPassword1Property = DataPropertyDescriptor <string> .Register("NewPassword1", typeof(LoginSession));

            NewPassword2Property = DataPropertyDescriptor <string> .Register("NewPassword2", typeof(LoginSession));

            LoginOperation    = OperationDescriptor.Register("Login", typeof(LoginSession));
            RegisterOperation = OperationDescriptor.Register("Register", typeof(LoginSession));
            OnStaticConstruction();
        }
Exemplo n.º 12
0
        protected void UpdateColumnFormats(bool restoreDefaultFormats)
        {
            var bindingListSource = DataSource as BindingListSource;

            if (bindingListSource == null)
            {
                return;
            }
            var newColumnFormats = ImmutableList.ValueOf(_itemProperties.Select(prop => bindingListSource.ColumnFormats.GetFormat(new ColumnId(prop.ColumnCaption))));

            if (Equals(newColumnFormats, _columnFormats))
            {
                return;
            }
            _columnFormats = newColumnFormats;
            foreach (var column in Columns.OfType <DataGridViewColumn>())
            {
                if (string.IsNullOrEmpty(column.DataPropertyName))
                {
                    continue;
                }
                DataPropertyDescriptor pd           = null;
                ColumnFormat           columnFormat = null;
                if (column.Index < _itemProperties.Count && _itemProperties[column.Index].Name == column.DataPropertyName)
                {
                    pd           = _itemProperties[column.Index];
                    columnFormat = _columnFormats[column.Index];
                }
                else
                {
                    for (int i = 0; i < _itemProperties.Count; i++)
                    {
                        if (_itemProperties[i].Name == column.DataPropertyName)
                        {
                            pd           = _itemProperties[i];
                            columnFormat = _columnFormats[i];
                        }
                    }
                }
                if (pd == null)
                {
                    continue;
                }
                if (null != columnFormat.Format)
                {
                    column.DefaultCellStyle.Format = columnFormat.Format;
                }
                else
                {
                    if (restoreDefaultFormats)
                    {
                        var originalColumn = _viewContext.CreateGridViewColumn(pd);
                        column.DefaultCellStyle.Format = originalColumn.DefaultCellStyle.Format;
                    }
                }
                if (columnFormat.Width.HasValue)
                {
                    column.Width = columnFormat.Width.Value;
                }
            }
        }
Exemplo n.º 13
0
 public ClusterRole.Transform GetRowTransform(DataPropertyDescriptor propertyDescriptor)
 {
     _rowTransforms.TryGetValue(propertyDescriptor.Name, out ClusterRole.Transform role);
     return(role);
 }
Exemplo n.º 14
0
        static MyApplicationSession()
        {
            SampleFlagProperty = DataPropertyDescriptor <bool> .Register("SampleFlag", typeof(MyApplicationSession));

            OnStaticConstruction();
        }
Exemplo n.º 15
0
 private CaptionedValues GetRowHeaderLevel(IList <RowItem> rowItems,
                                           DataPropertyDescriptor dataPropertyDescriptor)
 {
     return(new CaptionedValues(dataPropertyDescriptor.ColumnCaption, dataPropertyDescriptor.PropertyType, rowItems.Select(dataPropertyDescriptor.GetValue)));
 }
Exemplo n.º 16
0
        public IEnumerable <ColumnFilter> GetColumnFilters(DataPropertyDescriptor propertyDescriptor)
        {
            var columnId = ColumnId.GetColumnId(propertyDescriptor);

            return(ColumnFilters.Where(columnFilter => Equals(columnId, columnFilter.ColumnId)));
        }
Exemplo n.º 17
0
 public void QuickFilter(DataGridViewColumn column)
 {
     _columnFilterPropertyDescriptor = BindingListSource.FindDataProperty(column.DataPropertyName);
     filterToolStripMenuItem_Click(filterToolStripMenuItem, new EventArgs());
 }
Exemplo n.º 18
0
 public void ShowFormatDialog(DataGridViewColumn column)
 {
     _columnFilterPropertyDescriptor = BindingListSource.FindDataProperty(column.DataPropertyName);
     formatToolStripMenuItem_Click(formatToolStripMenuItem, new EventArgs());
 }
Exemplo n.º 19
0
 public static ColumnId GetColumnId(DataPropertyDescriptor dataPropertyDescriptor)
 {
     return(new ColumnId(dataPropertyDescriptor.ColumnCaption.GetCaption(DataSchemaLocalizer.INVARIANT)));
 }
Exemplo n.º 20
0
        static MyGeneratedClass()
        {
            SampleFlagProperty = DataPropertyDescriptor <bool> .Register("SampleFlag", typeof(MyGeneratedClass));

            OnStaticConstruction();
        }