private void DataFilterEditorCreated(object sender, EditorCreatedEventArgs e)
        {
            var propertyDefinition = (FieldPathPropertyDefinition)e.ItemPropertyDefinition;

            // fill States Combo
            if (propertyDefinition.PropertyName == Constants.CurrentStateGuidColumnName)
            {
                LoadStates(e);
                return;
            }

            switch (propertyDefinition.ColumnType)
            {
                case ColumnTypes.Reference:
                case ColumnTypes.MultiReference:
                    LoadCrossReferenceItems(propertyDefinition, e);
                    break;

                case ColumnTypes.ReverseReference:
                case ColumnTypes.ReverseMultiReference:
                case ColumnTypes.TreeView:
                    LoadReverseCrossReferenceItems(propertyDefinition, e);
                    break;

                case ColumnTypes.Numeric:
                    SetupNumericField(e);
                    break;
            }
        }
Exemplo n.º 2
0
        private void RadGridView_FieldFilterEditorCreated(object sender, EditorCreatedEventArgs e)
        {
            var stringFilterEditor = e.Editor as StringFilterEditor;

            if (stringFilterEditor != null)
            {
                // filtering with StringFilterEditor (when filtering string values)
                e.Editor.Loaded += (s1, e1) =>
                {
                    var textBox = e.Editor.ChildrenOfType<TextBox>().Single();
                    textBox.TextChanged += (s2, e2) =>
                    {
                        textBox.GetBindingExpression(TextBox.TextProperty).UpdateSource();
                    };
                };
            }
            else
            {
                // Filtering with TextBox editor (when filtering numeric values)
                var textBox = e.Editor as TextBox;
                if (textBox != null)
                {
                    textBox.TextChanged += (s2, e2) =>
                    {
                        textBox.GetBindingExpression(TextBox.TextProperty).UpdateSource();
                    };
                }
            }
        }
Exemplo n.º 3
0
        private void RadGridView_FieldFilterEditorCreated(object sender, EditorCreatedEventArgs e)
        {
            var stringFilterEditor = e.Editor as StringFilterEditor;

            if (stringFilterEditor != null)
            {
                // filtering with StringFilterEditor (when filtering string values)
                e.Editor.Loaded += (s1, e1) =>
                {
                    var textBox = e.Editor.ChildrenOfType <TextBox>().Single();
                    textBox.TextChanged += (s2, e2) =>
                    {
                        textBox.GetBindingExpression(TextBox.TextProperty).UpdateSource();
                    };
                };
            }
            else
            {
                // Filtering with TextBox editor (when filtering numeric values)
                var textBox = e.Editor as TextBox;
                if (textBox != null)
                {
                    textBox.TextChanged += (s2, e2) =>
                    {
                        textBox.GetBindingExpression(TextBox.TextProperty).UpdateSource();
                    };
                }
            }
        }
Exemplo n.º 4
0
        private void radDataFilter_EditorCreated(object sender, EditorCreatedEventArgs e)
        {
            switch (e.ItemPropertyDefinition.PropertyName)
            {
            case "BrandID":
                RadComboBox cbxBrand = (RadComboBox)e.Editor;
                cbxBrand.ItemsSource = VMGlobal.PoweredBrands;
                break;

            case "Year":
                RadDateTimePicker dateTimePickerEditor = (RadDateTimePicker)e.Editor;
                dateTimePickerEditor.DateSelectionMode        = DateSelectionMode.Year;
                dateTimePickerEditor.IsTooltipEnabled         = true;
                dateTimePickerEditor.ErrorTooltipContent      = "输入格式不正确";
                dateTimePickerEditor.DateTimeWatermarkContent = "选择年份";
                dateTimePickerEditor.SelectionChanged        += (ss, ee) =>
                {
                    DateTime date = (DateTime)ee.AddedItems[0];
                    dateTimePickerEditor.DateTimeText = date.Year.ToString();
                };
                break;

            case "Quarter":
                RadComboBox cbxQuarter = (RadComboBox)e.Editor;
                cbxQuarter.ItemsSource = VMGlobal.Quarters;
                break;
            }
        }
Exemplo n.º 5
0
 private void OnFieldFilterEditorCreated(object sender, EditorCreatedEventArgs e)
 {
     if (e.Column is CollectionPropertyColumn)
     {
         StringFilterEditor sfe = (StringFilterEditor)e.Editor;
         sfe.MatchCaseVisibility = Visibility.Collapsed;
     }
 }
Exemplo n.º 6
0
 private void OnFieldFilterEditorCreated(object sender, EditorCreatedEventArgs e)
 {
     if (e.Column is CollectionPropertyColumn)
     {
         StringFilterEditor sfe = (StringFilterEditor)e.Editor;
         sfe.MatchCaseVisibility = Visibility.Collapsed;
     }
 }
Exemplo n.º 7
0
 private void radDataFilter_EditorCreated(object sender, EditorCreatedEventArgs e)
 {
     if (e.ItemPropertyDefinition.PropertyName == "RoleID")
     {
         RadComboBox cbxRole = (RadComboBox)e.Editor;
         cbxRole.ItemsSource = RoleVM.RolesOfCurrentOrgnization;
     }
 }
Exemplo n.º 8
0
        private void radDataFilter_EditorCreated(object sender, EditorCreatedEventArgs e)
        {
            //ProductListVM context = this.DataContext as ProductListVM;

            switch (e.ItemPropertyDefinition.PropertyName)
            {
            case "BrandID":
                // This is a custom editor specified through the EditorTemplateSelector.
                RadComboBox cbxBrand = (RadComboBox)e.Editor;
                cbxBrand.ItemsSource = VMGlobal.PoweredBrands;
                break;

            case "Year":
                // This is a default editor.
                //RadDateTimePicker dateTimePickerEditor = (RadDateTimePicker)e.Editor;
                ////dateTimePickerEditor.InputMode = Telerik.Windows.Controls.InputMode.DatePicker;
                //dateTimePickerEditor.DateSelectionMode = DateSelectionMode.Year;
                //dateTimePickerEditor.IsTooltipEnabled = true;
                //dateTimePickerEditor.ErrorTooltipContent = "输入格式不正确";
                //dateTimePickerEditor.DateTimeWatermarkContent = "选择年份";
                //dateTimePickerEditor.SelectionChanged += (ss, ee) =>
                //{
                //    DateTime date = (DateTime)ee.AddedItems[0];
                //    dateTimePickerEditor.DateTimeText = date.Year.ToString();
                //};
                //break;
                RadDatePicker dateTimePickerEditor = (RadDatePicker)e.Editor;
                //dateTimePickerEditor.InputMode = Telerik.Windows.Controls.InputMode.DatePicker;
                dateTimePickerEditor.SelectionChanged += (ss, ee) =>
                {
                    DateTime date = (DateTime)ee.AddedItems[0];
                    dateTimePickerEditor.DateTimeText = date.Year.ToString();
                };
                break;

            case "BoduanID":
                RadComboBox cbxBoduan = (RadComboBox)e.Editor;
                cbxBoduan.ItemsSource = VMGlobal.Boduans;
                break;

            case "Quarter":
                RadComboBox cbxQuarter = (RadComboBox)e.Editor;
                cbxQuarter.ItemsSource = VMGlobal.Quarters;
                break;

            case "SizeID":
                RadComboBox cbxSize = (RadComboBox)e.Editor;
                cbxSize.ItemsSource = VMGlobal.Sizes;
                break;

            case "NameID":
                RadComboBox cbxName = (RadComboBox)e.Editor;
                cbxName.ItemsSource = VMGlobal.ProNames;
                break;
            }
            SysProcessView.UIHelper.ToggleShowEqualFilterOperatorOnly(e.Editor);
        }
Exemplo n.º 9
0
 private void radDataFilter_EditorCreated(object sender, EditorCreatedEventArgs e)
 {
     switch (e.ItemPropertyDefinition.PropertyName)
     {
     case "Title":
         (( RadComboBox )e.Editor).ItemsSource = this.GetTitles();
         break;
     }
 }
Exemplo n.º 10
0
        private void RadGridView_FieldFilterEditorCreated(object sender, EditorCreatedEventArgs e)
        {
            var stringFilterEditor = e.Editor as StringFilterEditor;

            if (stringFilterEditor != null)
            {
                e.Editor.Loaded += (s1, e1) =>
                {
                    var textBox = e.Editor.ChildrenOfType <TextBox>().Single();
                    textBox.TextChanged += (s2, e2) =>
                    {
                        textBox.GetBindingExpression(TextBox.TextProperty).UpdateSource();
                    };
                };
            }
        }
Exemplo n.º 11
0
        private void RadGridView_FieldFilterEditorCreated(object sender, EditorCreatedEventArgs e)
        {
            var stringFilterEditor = e.Editor as StringFilterEditor;

            if (stringFilterEditor != null)
            {
                e.Editor.Loaded += (s1, e1) =>
                {
                    var textBox = e.Editor.ChildrenOfType<TextBox>().Single();
                    textBox.TextChanged += (s2, e2) =>
                    {
                        textBox.GetBindingExpression(TextBox.TextProperty).UpdateSource();
                    };
                };
            }
        }
        private void radDataFilter_EditorCreated(object sender, EditorCreatedEventArgs e)
        {
            switch (e.ItemPropertyDefinition.PropertyName)
            {
            case "BrandID":
                // This is a custom editor specified through the EditorTemplateSelector.
                RadComboBox cbxBrand = (RadComboBox)e.Editor;
                cbxBrand.ItemsSource = VMGlobal.PoweredBrands;
                break;

            case "NameID":
                RadComboBox cbxName = (RadComboBox)e.Editor;
                cbxName.ItemsSource = VMGlobal.ProNames;
                break;
            }
            SysProcessView.UIHelper.ToggleShowEqualFilterOperatorOnly(e.Editor);
        }
Exemplo n.º 13
0
        private void radDataFilter_EditorCreated(object sender, EditorCreatedEventArgs e)
        {
            switch (e.ItemPropertyDefinition.PropertyName)
            {
            case "BrandID":
                // This is a custom editor specified through the EditorTemplateSelector.
                RadComboBox cbxBrand = (RadComboBox)e.Editor;
                cbxBrand.ItemsSource = VMGlobal.PoweredBrands;
                break;

            case "Year":
                // This is a default editor.
                RadDatePicker dateTimePickerEditor = (RadDatePicker)e.Editor;
                //dateTimePickerEditor.InputMode = Telerik.Windows.Controls.InputMode.DatePicker;
                dateTimePickerEditor.SelectionChanged += (ss, ee) =>
                {
                    DateTime date = (DateTime)ee.AddedItems[0];
                    dateTimePickerEditor.DateTimeText = date.Year.ToString();
                };
                break;

            case "Quarter":
                RadComboBox cbxQuarter = (RadComboBox)e.Editor;
                cbxQuarter.ItemsSource = VMGlobal.Quarters;
                break;

            case "NameID":
                RadComboBox cbxName = (RadComboBox)e.Editor;
                cbxName.ItemsSource = VMGlobal.ProNames;
                break;

            case "SizeID":
                RadComboBox cbxSize = (RadComboBox)e.Editor;
                cbxSize.ItemsSource = VMGlobal.Sizes;
                break;

            case "StorageID":
                RadComboBox cbxStorage = (RadComboBox)e.Editor;
                cbxStorage.ItemsSource = StorageInfoVM.Storages;
                break;
            }
            SysProcessView.UIHelper.ToggleShowEqualFilterOperatorOnly(e.Editor);
        }
Exemplo n.º 14
0
        private void SetupCheckBoxField(EditorCreatedEventArgs e)
        {
            var checkBox = e.Editor.FindChildByType<CheckBox>();

            if (checkBox != null)
            {
                var weakListener = new WeakEventListener<FilterSetupView, FrameworkElement, DependencyPropertyChangedEventArgs>(this, checkBox);
                checkBox.DataContextChanged += weakListener.OnEvent;
                weakListener.OnEventAction += CheckBoxOnDataContextChanged;
                weakListener.OnDetachAction += DetachFromDataContextChangedEvent;

                var filterViewModel = (SimpleFilterViewModel)e.Editor.DataContext;

                if (filterViewModel != null && filterViewModel.Value == OperatorValueFilterDescriptorBase.UnsetValue)
                {
                    filterViewModel.Value = null;
                }
            }
        }
Exemplo n.º 15
0
        private void LoadReferenceItems(
            string processName, 
            string referenceField, 
            string filterExpression, 
            EditorCreatedEventArgs e, 
            string displayField)
        {
            var sortDescriptors = new SortList {new SortDescriptor(displayField, SortDirection.Ascending)};

            var vm = DataContext as SearchListViewModel;
            if (vm == null)
            {
                return;
            }

            vm.TheDynamicTypeManager.Value.BeginGetCrossReferenceList(
                processName,
                referenceField,
                (o2, result2) =>
                    {
                        if (result2.Error == null)
                        {
                            var infoList = result2.Object;
                            var comboBox = e.Editor.FindChildByType<RadComboBox>();

                            if (comboBox != null)
                            {
                                dataFilter.Tag = true;
                                comboBox.ItemsSource = infoList;
                                comboBox.SelectedValuePath = "Id";

                                Observable.FromEventPattern<SelectionChangedEventHandler, SelectionChangedEventArgs>(
                                    handler => comboBox.SelectionChanged += handler, handler => comboBox.SelectionChanged -= handler)
                                          .SubscribeWeakly(this, (target, handler) => target.ComboBoxOnSelectionChanged(handler.Sender, handler.EventArgs));

                                var itemType = vm.TheDynamicTypeManager.Value.GetCrossReferenceItemType(processName, referenceField);
                                comboBox.ItemTemplate = CreateTemplateForReferenceField(itemType, displayField);
                                TextSearch.SetTextPath(comboBox, displayField);

                                var filterViewModel = (SimpleFilterViewModel)e.Editor.DataContext;
                                if (filterViewModel != null && filterViewModel.Descriptor != null)
                                {
                                    var placeholder = filterViewModel.Descriptor.Value as IInfoClass;
                                    if (placeholder != null)
                                        comboBox.SelectedValue = placeholder.Id;
                                }

                                dataFilter.Tag = null;
                            }
                        }
                        else
                            vm.ThePopupFactory.Value.NotifyFailure(result2.Error);
                    },
                sortDescriptors,
                string.Empty,
                int.MaxValue,
                0,
                filterExpression);
        }
        private async void LoadCrossReferenceItems(FieldPathPropertyDefinition propertyDefinition, EditorCreatedEventArgs e)
        {
            if (string.IsNullOrEmpty(propertyDefinition.ReferencedProcessSystemName))
            {
                return;
            }

            var busyIndicator = e.Editor.FindChildByType<RadBusyIndicator>();
            if (busyIndicator != null)
            {
                busyIndicator.IsBusy = true;
            }

            try
            {
                string filterExpression = null;
                if (propertyDefinition.SystemName == Constants.CurrentStateColumnName)
                {
                    // If it's a CurrentState filter, show only declaring process states.
                    var filterDescriptor = new FilterDescriptor(
                        Constants.ProcessFieldName,
                        FilterOperator.IsEqualTo,
                        propertyDefinition.DeclaringProcessSystemName,
                        typeof(string));

                    filterExpression = filterDescriptor.ToJSON();
                }

                var displayFieldName = propertyDefinition.ReferencedFieldSystemName == "AqlDetail" ? Constants.AqlDisplayField : propertyDefinition.ReferencedFieldSystemName;

                var infoList =
                    await
                    DynamicTypeManager.GetInfoListAsync<IInfoClass>(
                        propertyDefinition.ReferencedProcessSystemName,
                        int.MaxValue,
                        0,
                        filterExpression,
                        null,
                        new SortList { new SortDescriptor(displayFieldName, SortDirection.Ascending) });

                var comboBox = e.Editor.FindChildByType<RadComboBox>();
                if (comboBox == null)
                {
                    return;
                }

                dataFilter.Tag = true;

                try
                {
                    comboBox.ItemsSource = infoList;
                    comboBox.SelectedValuePath = "Id";

                    Observable.FromEventPattern<SelectionChangedEventHandler, SelectionChangedEventArgs>(
                        handler => comboBox.SelectionChanged += handler,
                        handler => comboBox.SelectionChanged -= handler).SubscribeWeakly(this, OnComboBoxSelectionChanged);

                    if (infoList != null)
                    {
                        comboBox.DisplayMemberPath = string.Join(".", infoList.ElementType.GetFullPropertyPath(displayFieldName));
                    }

                    var filterViewModel = (SimpleFilterViewModel)e.Editor.DataContext;
                    if (filterViewModel != null && filterViewModel.Descriptor != null)
                    {
                        var placeholder = filterViewModel.Descriptor.Value as IInfoClass;
                        if (placeholder != null)
                        {
                            comboBox.SelectedValue = placeholder.Id;
                        }
                    }
                }
                finally
                {
                    dataFilter.Tag = null;
                }
            }
            catch (DataPortalException ex)
            {
                PopupFactory.NotifyFailure(ex);
            }
            finally
            {
                if (busyIndicator != null)
                {
                    busyIndicator.IsBusy = false;
                }
            }
        }
        private async void LoadReverseCrossReferenceItems(FieldPathPropertyDefinition propertyDefinition, EditorCreatedEventArgs e)
        {
            if (string.IsNullOrEmpty(propertyDefinition.ReferencedProcessSystemName))
            {
                return;
            }

            try
            {
                var displayField = propertyDefinition.ReferencedFieldSystemName;
                var filter = new FilterDescriptor(propertyDefinition.LinkFieldSystemName, FilterOperator.IsGreaterThan, 0, typeof(int));

                var infoList =
                    await
                    DynamicTypeManager.GetInfoListAsync<IInfoClass>(
                        propertyDefinition.ReferencedProcessSystemName,
                        int.MaxValue,
                        0,
                        filter.ToJSON(),
                        null,
                        new SortList { new SortDescriptor(displayField, SortDirection.Ascending) });

                var comboBox = e.Editor.FindChildByType<RadComboBox>();
                if (comboBox == null)
                {
                    return;
                }

                dataFilter.Tag = true;
                try
                {
                    comboBox.ItemsSource = infoList;
                    comboBox.SelectedValuePath = "Id";
                    Observable.FromEventPattern<SelectionChangedEventHandler, SelectionChangedEventArgs>(
                        handler => comboBox.SelectionChanged += handler,
                        handler => comboBox.SelectionChanged -= handler).SubscribeWeakly(this, OnComboBoxSelectionChanged);

                    if (infoList != null)
                    {
                        //comboBox.ItemTemplate = CreateTemplateForReferenceField((IInfoClass) infoList[0], displayField);
                        comboBox.DisplayMemberPath = string.Join(".", infoList.ElementType.GetFullPropertyPath(displayField));
                    }

                    var filterViewModel = (SimpleFilterViewModel)e.Editor.DataContext;
                    if (filterViewModel != null && filterViewModel.Descriptor != null)
                    {
                        var placeholder = filterViewModel.Descriptor.Value as IInfoClass;
                        if (placeholder != null)
                        {
                            comboBox.SelectedValue = placeholder.Id;
                        }
                    }
                }
                finally
                {
                    dataFilter.Tag = null;
                }
            }
            catch (DataPortalException ex)
            {
                PopupFactory.NotifyFailure(ex);
            }
        }
Exemplo n.º 18
0
        private bool SetupStateCombobox(EditorCreatedEventArgs e, ISearchListViewModel viewModel)
        {
            //Commented - use new View FilterSetupView
            return false;
            //if (viewModel.Collection != null && ((IList) viewModel.Collection).Count > 0)
            //{
            //    var comboBox = e.Editor.FindChildByType<RadComboBox>();

            //    if (comboBox != null)
            //    {
            //        dataFilter.Tag = true;

            //        dynamic info = ((IList) viewModel.Collection)[0];

            //        var states = info.StateInfoManager.States;

            //        comboBox.ItemsSource = states;
            //        comboBox.SelectedValuePath = "Id";
            //        comboBox.DisplayMemberPath = "Name";

            //        Observable.FromEventPattern<SelectionChangedEventHandler, SelectionChangedEventArgs>(
            //            handler => comboBox.SelectionChanged += handler, handler => comboBox.SelectionChanged -= handler)
            //            .SubscribeWeakly(this, (target, handler) => target.ComboBoxOnSelectionChanged(handler.Sender, handler.EventArgs));

            //        var weakListener = new WeakEventListener<FilteringView, RadComboBox, DependencyPropertyChangedEventArgs>(this, comboBox);
            //        comboBox.DataContextChanged += weakListener.OnEvent;
            //        weakListener.OnEventAction += ComboBoxOnDataContextChanged;
            //        weakListener.OnDetachAction += (listener, source) => { source.DataContextChanged -= listener.OnEvent; };

            //        var filterViewModel = (SimpleFilterViewModel) e.Editor.DataContext;
            //        if (filterViewModel != null && filterViewModel.Descriptor != null)
            //        {
            //            var placeholder = filterViewModel.Descriptor.Value as IInfoClass;
            //            if (placeholder != null)
            //                comboBox.SelectedValue = placeholder.Id;
            //        }

            //        dataFilter.Tag = null;
            //        return true;
            //    }
            //}
            //return false;
        }
Exemplo n.º 19
0
        private async void LoadReferenceItems(
            string processName,
            string referenceField,
            string filterExpression,
            EditorCreatedEventArgs e,
            string displayField)
        {
            var context = DataContext as IFilterSetupViewModel;
            var isCurrentStateGuidFilter = false;
            if (context != null)
            {
                isCurrentStateGuidFilter = !context.IsUserFilter && (referenceField == Constants.CurrentStateColumnName)
                                           && (processName == context.ProcessSystemName);
            }

            var sortDescriptors = new SortList { new SortDescriptor(displayField) };

            //enforce SearchQueryGenerator to adjust Guid field into SQL query. required to find CurrentState by a guid. Admin filters use guid to identify States unlike UserFilters.
            if (isCurrentStateGuidFilter)
            {
                sortDescriptors.Add(new SortDescriptor("Guid", SortDirection.Ascending));
            }

            try
            {
                var infoList =
                    await
                    DynamicTypeManager.GetCrossReferenceListAsync<IReferenceItem>(
                        processName,
                        referenceField,
                        sortDescriptors,
                        null,
                        int.MaxValue,
                        0,
                        filterExpression);

                var comboBox = e.Editor.FindChildByType<RadComboBox>();
                if (comboBox == null)
                {
                    return;
                }

                DataFilter.Tag = true;
                try
                {
                    comboBox.ItemsSource = infoList;
                    comboBox.SelectedValuePath = isCurrentStateGuidFilter ? "Guid" : "Id";

                    Observable.FromEventPattern<SelectionChangedEventHandler, SelectionChangedEventArgs>(
                        handler => comboBox.SelectionChanged += handler,
                        handler => comboBox.SelectionChanged -= handler).SubscribeWeakly(this, OnComboBoxSelectionChanged);

                    var itemType = DynamicTypeManager.GetCrossReferenceItemType(processName, referenceField);
                    //comboBox.ItemTemplate = CreateTemplateForReferenceField(itemType, displayField);

                    var displayFieldList = GetDisplayFieldList(processName, referenceField);

                    comboBox.ItemTemplate = CreateTemplateForReferenceField(displayFieldList, itemType, displayField);
                    TextSearch.SetTextPath(comboBox, displayField);

                    var filterViewModel = (SimpleFilterViewModel)e.Editor.DataContext;
                    if (filterViewModel != null && filterViewModel.Descriptor != null)
                    {
                        var stateInfo = filterViewModel.Descriptor.Value as StateInfoClass;
                        if (stateInfo != null)
                        {
                            var placeholder = stateInfo;
                            comboBox.SelectedValue = placeholder.Guid.ToString();

                            //workaround - some state Guids are lower case and some upper
                            if (comboBox.SelectedValue == null)
                            {
                                comboBox.SelectedValue = placeholder.Guid.ToString().ToUpperInvariant();
                            }
                        }
                        else if (filterViewModel.Descriptor.Value is IInfoClass)
                        {
                            var placeholder = filterViewModel.Descriptor.Value as IInfoClass;
                            comboBox.SelectedValue = placeholder.Id;
                        }
                    }
                }
                finally
                {
                    DataFilter.Tag = null;
                }
            }
            catch (DataPortalException ex)
            {
                PopupFactory.NotifyFailure(ex);
            }
        }
Exemplo n.º 20
0
        private void SetupTreeViewField(FieldPathPropertyDefinition propertyDefinition, EditorCreatedEventArgs e)
        {
            var linkField = propertyDefinition.LinkFieldSystemName;
            if (linkField != Constants.IdColumnName)
            {
                linkField += Constants.IdColumnName;
            }

            var filter = new FilterDescriptor(linkField, FilterOperator.IsNotEqualTo, null, typeof(int));

            LoadReferenceItems(propertyDefinition.DeclaringProcessSystemName, propertyDefinition.SystemName, filter.ToJSON(), e, propertyDefinition.ReferencedFieldSystemName);
        }
Exemplo n.º 21
0
        private void SetupCrossReferenceField(FieldPathPropertyDefinition propertyDefinition, EditorCreatedEventArgs e)
        {
            var crProcessName = propertyDefinition.ReferencedProcessSystemName;
            var displayField = propertyDefinition.ReferencedFieldSystemName;

            FilterDescriptor filterDescriptor = null;
            if (Constants.StateProcessName.Equals(crProcessName) && !string.IsNullOrEmpty(propertyDefinition.DeclaringProcessSystemName))
            {
                filterDescriptor = new FilterDescriptor(
                    Constants.ProcessFieldName,
                    FilterOperator.IsEqualTo,
                    propertyDefinition.DeclaringProcessSystemName,
                    typeof(string));
            }

            var filter = filterDescriptor == null ? string.Empty : filterDescriptor.ToJSON();

            LoadReferenceItems(propertyDefinition.DeclaringProcessSystemName, propertyDefinition.SystemName, filter, e, displayField);
        }
Exemplo n.º 22
0
        private void DataFilterEditorCreated(object sender, EditorCreatedEventArgs e)
        {
            var viewModel = DataContext as ISearchListViewModel;

            if (viewModel == null)
                return;

            var fieldName = e.ItemPropertyDefinition.PropertyName;
            if (fieldName.EndsWith("Id", StringComparison.Ordinal))
            {
                fieldName = fieldName.Substring(0, fieldName.Length - 2);
            }

            var column = ((IDynamicList)DataContext).Columns[fieldName];
            
            if (column == null)
            {
                return;
            }

            if (fieldName == Constants.CurrentStateColumnName && SetupStateCombobox(e, viewModel)) 
                return;

            if (!string.IsNullOrEmpty(column.ReferenceTableName))
            {
                var crProcessName = column.ReferenceTableName;

                var type = column.Property.DeclaringType;
                var processInfoAttr = (ProcessInfoAttribute)type.GetCustomAttributes(typeof(ProcessInfoAttribute), false).First();

                var displayField = ((CrossRefFieldAttribute)(column.Property.GetCustomAttributes(typeof (CrossRefFieldAttribute), true).First())).RefFieldName;

                FilterDescriptor filterDescriptor = null;
                if (Constants.StateProcessName.Equals(crProcessName) && !string.IsNullOrEmpty(viewModel.ProcessSystemName))
                {
                    filterDescriptor = new FilterDescriptor(Constants.ProcessFieldName, FilterOperator.IsEqualTo, viewModel.ProcessSystemName, typeof(string));
                }

                var filter = filterDescriptor == null ? string.Empty : filterDescriptor.ToJSON();

                LoadReferenceItems(processInfoAttr.Name, fieldName, filter, e, displayField);
            }


            if (FilteringUtils.IsReverseReference(column.Property))
            {
                var rcrAttr = (ReverseCrossRefFieldAttribute)column.Property.GetCustomAttributes(typeof(ReverseCrossRefFieldAttribute), false).FirstOrDefault();
                if (rcrAttr == null)
                    return;

                var filter = new FilterDescriptor(rcrAttr.CrossReferenceFieldName + Constants.IdColumnName, FilterOperator.IsNotEqualTo, null) { MemberType = typeof(int) };

                LoadReferenceItems(viewModel.ProcessSystemName, column.Property.Name, filter.ToJSON(), e, rcrAttr.RefFieldName);
            }

            if (FilteringUtils.IsApproval(column.Property))
            {
                var comboBox = e.Editor.FindChildByType<RadComboBox>();

                if (comboBox != null)
                {
                    dataFilter.Tag = true;

                    var approvalStates = typeof(ApprovalStates).GetFields().Where(f => f.IsLiteral).Select(state => (ApprovalStates)state.GetValue(null)).ToList();

                    comboBox.ItemsSource = approvalStates;

                    Observable.FromEventPattern<SelectionChangedEventHandler, SelectionChangedEventArgs>(
                        handler => comboBox.SelectionChanged += handler, handler => comboBox.SelectionChanged -= handler)
                              .SubscribeWeakly(this, (target, handler) => target.ComboBoxOnSelectionChanged(handler.Sender, handler.EventArgs));

                    var weakListener = new WeakEventListener<FilteringView, RadComboBox, DependencyPropertyChangedEventArgs>(this, comboBox);
                    comboBox.DataContextChanged += weakListener.OnEvent;
                    weakListener.OnEventAction += ComboBoxOnDataContextChanged;
                    weakListener.OnDetachAction += (listener, source) => { source.DataContextChanged -= listener.OnEvent; };

                    dataFilter.Tag = null;
                }
            }

            if (FilteringUtils.IsNumeric(column.Property))
            {
                var numericUpDown = e.Editor.FindChildByType<RadNumericUpDown>();

                if (numericUpDown != null)
                {
                    var weakListener =
                        new WeakEventListener<FilteringView, RadNumericUpDown, DependencyPropertyChangedEventArgs>(
                            this, numericUpDown);
                    numericUpDown.DataContextChanged += weakListener.OnEvent;
                    weakListener.OnEventAction += NumericUpDownOnDataContextChanged;
                    weakListener.OnDetachAction +=
                        (listener, source) => { source.DataContextChanged -= listener.OnEvent; };

                    var filterViewModel = (SimpleFilterViewModel)e.Editor.DataContext;

                    if (filterViewModel != null && filterViewModel.Value == OperatorValueFilterDescriptorBase.UnsetValue)
                    {
                        filterViewModel.Value = null;
                    }
                }
            }

            if (FilteringUtils.IsNullableBool(column.Property))
            {
                var checkBox = e.Editor.FindChildByType<CheckBox>();

                if (checkBox != null)
                {
                    var weakListener = new WeakEventListener<FilteringView, CheckBox, DependencyPropertyChangedEventArgs>(this, checkBox);
                    checkBox.DataContextChanged += weakListener.OnEvent;
                    weakListener.OnEventAction += CheckBoxOnDataContextChanged;
                    weakListener.OnDetachAction += (listener, source) => { source.DataContextChanged -= listener.OnEvent; };

                    var filterViewModel = (SimpleFilterViewModel)e.Editor.DataContext;

                    if (filterViewModel != null && filterViewModel.Value == OperatorValueFilterDescriptorBase.UnsetValue)
                    {
                        filterViewModel.Value = null;
                    }
                }
            }
        }
        private void LoadStates(EditorCreatedEventArgs e)
        {
            var viewModel = DataContext as IProcessFiltersTabViewModel;
            if (viewModel == null)
            {
                return;
            }

            var process = viewModel.Model;
            if (process == null)
            {
                return;
            }

            var comboBox = e.Editor.FindChildByType<RadComboBox>();
            if (comboBox != null)
            {
                var infoList = new CustomInfoList();
                foreach (var state in process.StateList.OrderBy(s => s.Name))
                {
                    infoList.Add(new StateInfoClass { Id = state.Id, Guid = state.Guid, Name = state.Name });
                }

                dataFilter.Tag = true;
                comboBox.ItemsSource = infoList;
                comboBox.SelectedValuePath = "Guid";
                comboBox.DisplayMemberPath = Constants.Name;

                Observable.FromEventPattern<SelectionChangedEventHandler, SelectionChangedEventArgs>(
                    handler => comboBox.SelectionChanged += handler,
                    handler => comboBox.SelectionChanged -= handler).SubscribeWeakly(this, OnComboBoxSelectionChanged);

                var weakListener = new WeakEventListener<ProcessFilterDetailsView, FrameworkElement, DependencyPropertyChangedEventArgs>(this, comboBox);
                comboBox.DataContextChanged += weakListener.OnEvent;
                weakListener.OnEventAction = OnStateComboBoxDataContextChanged;
                weakListener.OnDetachAction = DetachFromDataContextChangedEvent;
            }
        }
        private void StcDocumentHeaderRadGridView_FieldFilterEditorCreated(object sender, EditorCreatedEventArgs e)
        {
            //get the StringFilterEditor in your RadGridView
            var stringFilterEditor = e.Editor as StringFilterEditor;

            if (stringFilterEditor != null)
            {
                stringFilterEditor.MatchCaseVisibility = Visibility.Hidden;
            }
        }
Exemplo n.º 25
0
        private void DataFilterEditorCreated(object sender, EditorCreatedEventArgs e)
        {
            var propertyDefinition = (FieldPathPropertyDefinition)e.ItemPropertyDefinition;

            switch (propertyDefinition.ColumnType)
            {
                case ColumnTypes.Reference:
                case ColumnTypes.MultiReference:
                    {
                        SetupCrossReferenceField(propertyDefinition, e);
                        return;
                    }

                case ColumnTypes.ReverseReference:
                case ColumnTypes.ReverseMultiReference:
                    {
                        SetupReverseCrossReferenceField(propertyDefinition, e);
                        return;
                    }

                case ColumnTypes.TreeView:
                    {
                        SetupTreeViewField(propertyDefinition, e);
                        return;
                    }
            }

            var infoType = DynamicTypeManager.GetInfoType(propertyDefinition.DeclaringProcessSystemName);
            if (infoType == null)
            {
                return;
            }

            var property = infoType.GetPropertyByName(propertyDefinition.SystemName);
            if (property == null)
            {
                return;
            }

            if (FilteringUtils.IsNumeric(property))
            {
                SetupNumericField(e);
            }

            if (FilteringUtils.IsNullableBool(property))
            {
                SetupCheckBoxField(e);
            }
        }
Exemplo n.º 26
0
        private void SetupNumericField(EditorCreatedEventArgs e)
        {
            var numericUpDown = e.Editor.FindChildByType<RadNumericUpDown>();

            if (numericUpDown != null)
            {
                var weakListener = new WeakEventListener<FilterSetupView, FrameworkElement, DependencyPropertyChangedEventArgs>(this, numericUpDown);
                numericUpDown.DataContextChanged += weakListener.OnEvent;
                weakListener.OnEventAction += NumericUpDownOnDataContextChanged;
                weakListener.OnDetachAction += DetachFromDataContextChangedEvent;

                var filterViewModel = (SimpleFilterViewModel)e.Editor.DataContext;

                if (filterViewModel != null && filterViewModel.Value == OperatorValueFilterDescriptorBase.UnsetValue)
                {
                    filterViewModel.Value = null;
                }
            }
        }