Ejemplo n.º 1
0
        public void OnEventHandler(ComboValueSelectedAggEvent e)
        {
            Transaction tempTransaction = new Transaction();
            string      catName         = tempTransaction.GetName(() => tempTransaction.Category);
            string      subName         = tempTransaction.GetName(() => tempTransaction.SubCategory);

            TransactionRowModel row = e.EditedObject as TransactionRowModel;


            if (e.PropertyName == catName)
            {
                row.Item.IsEdited = true;


                AggEventCategoriesNeeded eventCategories = new AggEventCategoriesNeeded();
                _eventAggregator.PublishEvent <AggEventCategoriesNeeded>(eventCategories);

                Category category = eventCategories.Categories.GetCategoryByName(e.NewValue);
                row.Item.Color = category.Color;

                SubCategory firstSubCategory = category.SubCategories.FirstOrDefault();
                if (firstSubCategory.IsNotNullObj())
                {
                    row.Item.SubCategory = firstSubCategory.Name;
                }
            }

            if (e.PropertyName == subName)
            {
                row.Item.IsEdited = true;
            }

            _grid.Refresh();
            _grid.Invalidate();
        }
Ejemplo n.º 2
0
        void comboBox1_LostFocus(object sender, EventArgs e)
        {
            _combo.Visible = false;
            if (_isEscaping)
            {
                return;
            }

            PropertyInfo propInfo = _item.GetType().GetProperty(_propertyName);

            object oldValue = propInfo.GetValue(_item);

            object value = _combo.SelectedItem;

            propInfo.SetValue(_item, value, null);

            ComboValueSelectedAggEvent valueSelectedEvent = new ComboValueSelectedAggEvent()
            {
                EditedObject = _item,
                NewValue     = value as string,
                OldValue     = oldValue as string,
                PropertyName = _propertyName
            };

            _aggregator.PublishEvent <ComboValueSelectedAggEvent>(valueSelectedEvent);
        }