Exemplo n.º 1
0
 private void btnRemove_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         FilterItem curItem = (FilterItem)((ListBoxItem)lbMain.ContainerFromElement((Button)sender)).Content;
         if (_viewModel.FilterItems.Count < 1)       //if (FcItems.Count > 1)
         {
             _viewModel.FilterItems.Remove(curItem); //FcItems.Remove(curItem);
             lbMain.Items.Refresh();
         }
     }
     catch { }
 }
Exemplo n.º 2
0
        private void addFilterItem()
        {
            var fi = new FilterItem();

            fi.Field = GetFirstVisibleField();
            switch (fi.Field.FieldType)
            {
            case Strings4Enums.qFieldType.iDateTime:
                fi.Clauses = Strings4Enums.qClauses.GreaterThanOrEqualTo;
                break;

            case Strings4Enums.qFieldType.iNumber:
                fi.Clauses = Strings4Enums.qClauses.GreaterThanOrEqualTo;
                break;

            case Strings4Enums.qFieldType.iText:
                fi.Clauses = Strings4Enums.qClauses.Contains;
                break;

            case Strings4Enums.qFieldType.iBoolean:
                fi.Clauses = Strings4Enums.qClauses.iTrue;
                break;

            default:
                break;
            }
            _viewModel.FilterItems.Add(fi);//FcItems.Add(fi);//return fi;
            int pos = lbMain.Items.Count - 1;

            if (pos == 0)
            {
                lbMain.Items.Refresh();
            }
            ListBoxItem item = lbMain.ItemContainerGenerator.ContainerFromIndex(pos) as ListBoxItem;

            Infragistics.Controls.Editors.XamMultiColumnComboEditor ce = null;
            if (item != null)
            {
                try
                {
                    ce = VisualTree.FindFirstElementInVisualTree <Infragistics.Controls.Editors.XamMultiColumnComboEditor>(item);
                    ce.SelectedIndex = fi.Field.FieldPosition;
                }
                catch (Exception ex)
                { Console.WriteLine(ex.Message); }
            }
        }
Exemplo n.º 3
0
        private void cboFieldName_SelectionChanged(object sender, Infragistics.Controls.Editors.SelectionChangedEventArgs e)
        {
            if (sender is Infragistics.Controls.Editors.XamMultiColumnComboEditor)
            {
                Infragistics.Controls.Editors.XamMultiColumnComboEditor cb = sender as Infragistics.Controls.Editors.XamMultiColumnComboEditor;

                if (cb.SelectedIndex == -1)
                {
                    return;
                }
                FilterItem curItem = (FilterItem)((ListBoxItem)lbMain.ContainerFromElement(cb)).Content; //FcItems[lbMain.SelectedIndex];
                if (curItem != null)
                {
                    cField prevITem = null; try { prevITem = e.RemovedItems[0] as cField; } catch { }
                    //curItem.Field = e.AddedItems[0] as cField;
                    FcItems_Set_newField_Value(curItem, e.AddedItems[0] as cField);

                    int pos = lbMain.Items.IndexOf(curItem);
                    //dynamic item = lbMain.[pos];
                    ListBoxItem item = lbMain.ItemContainerGenerator.ContainerFromIndex(pos) as ListBoxItem;
                    System.Windows.Controls.Image imgtype = VisualTree.FindFirstElementInVisualTree <System.Windows.Controls.Image>(item);
                    if (prevITem != null && curItem.Field != null && prevITem.FieldType != curItem.Field.FieldType)
                    {
                        imgtype.Tag    = Enum.GetName(typeof(Strings4Enums.qFieldType), curItem.Field.FieldType);
                        imgtype.Source = new ImageSourceConverter().ConvertFromString(getImageAttr_Type(curItem.Field.FieldType)) as ImageSource;
                    }
                    ComboBox cboAttrClause = VisualTree.SearchVisualTreeForCombo(item, "cboClause");


                    if (cboAttrClause != null)
                    {
                        Debug.WriteLine(cboAttrClause.Name);
                        oClausesLoad(_CaseSensitive);
                        cboAttrClause.ItemsSource       = oClauses.Where(c => c.Attr_Type == curItem.Field.FieldType);
                        cboAttrClause.DisplayMemberPath = "Text"; cboAttrClause.SelectedValuePath = "Attr_Clause";
                        cboAttrClause.SelectedIndex     = 0;
                        //curItem.Clauses = ((dynamic)cboAttrClause.SelectedItem).Attr_Clause;
                        FcItems_Set_newClause_Value(curItem, ((dynamic)cboAttrClause.SelectedItem).Attr_Clause);
                    }
                    //FcItems[FcItems.IndexOf(curItem)].Field =  curItem.Field;
                    //         FcItems[pos].Clauses = curItem.Clauses;
                    //Debug.WriteLine(curItem.Field.FieldName);
                }
            }
        }
Exemplo n.º 4
0
 void FcItems_Set_newField_Value(FilterItem curItem, cField newField)
 {
     foreach (var fcitem in _viewModel.FilterItems) //foreach (var fcitem in FcItems)
     {
         if (fcitem == curItem)
         {
             System.Reflection.PropertyInfo[] Fields = fcitem.GetType().GetProperties();
             foreach (System.Reflection.PropertyInfo field in Fields)
             {
                 var currentField = field.GetValue(fcitem, null);
                 if (field.PropertyType.Name == "cField")
                 {
                     field.SetValue(fcitem, newField);
                     return;
                 }
             }
         }
     }
 }
Exemplo n.º 5
0
 private void btnAdd_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         //  Button s = (Button)sender;
         FilterItem curItem = (FilterItem)((ListBoxItem)lbMain.ContainerFromElement((Button)sender)).Content;
         //FcItems.Add();
         //{ AndOr = qLogOper.iAnd, FieldName = "FN" + FcItems.Count, Clause = Clauses.Contains, FieldAlias = "FA" + FcItems.Count }
         //var fi = addFilterItem();
         //fi.Field = fiel
         //FcItems.Add(fi);
         addFilterItem();
         if (_viewModel.FilterItems.Count > 0)//if (FcItems.Count > 0)
         {
             //lbMain.ScrollIntoView(FcItems.Last());
             lbMain.ScrollIntoView(_viewModel.FilterItems.Last());
         }
         //    new FilterItem()
         // lbMain.Items.Refresh();
     }
     catch { }
 }
Exemplo n.º 6
0
        private void cboClause_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            int cbv1w_when_cbv2_is_not_visible = 298;
            int cbv1w_when_cbv2_is_visible     = 130;

            ComboBox cboClause = sender as ComboBox;

            if (cboClause.SelectedIndex == -1)
            {
                return;
            }
            Clauses C = e.AddedItems[0] as Clauses;

            FilterItem curItem = (FilterItem)((ListBoxItem)lbMain.ContainerFromElement(cboClause)).Content;

            if (curItem != null)
            {
                var prevITem = curItem.Field;
                curItem.Field = e.AddedItems[0] as cField;
                int pos = lbMain.Items.IndexOf(curItem);
                //dynamic item = lbMain.[pos];
                ListBoxItem item = lbMain.ItemContainerGenerator.ContainerFromIndex(pos) as ListBoxItem;

                ComboBox cbv1   = VisualTree.SearchVisualTreeForCombo(item, "cboValue1");
                ComboBox cbv2   = VisualTree.SearchVisualTreeForCombo(item, "cboValue2");
                Button   bPaste = VisualTree.SearchVisualTreeForButton(item, "btnPaste");
                Label    _lbl_2Values_Separator = VisualTree.FindFirstElementInVisualTree <Label>(item);
                //Grid grid = VisualTree.FindFirstElementInVisualTree<Grid>(item);
                switch (C.Attr_Clause)
                {
                case Strings4Enums.qClauses.Between:
                case Strings4Enums.qClauses.NotBetween:
                    cbv1.Visibility   = Visibility.Visible; cbv1.Width = cbv1w_when_cbv2_is_visible;
                    cbv2.Visibility   = Visibility.Visible; _lbl_2Values_Separator.Visibility = Visibility.Visible;
                    bPaste.Visibility = Visibility.Hidden; bPaste.IsEnabled = false;
                    break;

                case Strings4Enums.qClauses.IsNull:
                case Strings4Enums.qClauses.IsEmpty:
                case Strings4Enums.qClauses.NotIsNull:
                    cbv1.Visibility = Visibility.Hidden; cbv2.Visibility = Visibility.Hidden;
                    _lbl_2Values_Separator.Visibility = Visibility.Hidden;
                    bPaste.Visibility = Visibility.Hidden; bPaste.IsEnabled = false;
                    break;

                case Strings4Enums.qClauses.iIn:
                case Strings4Enums.qClauses.NotIn:
                    cbv1.Visibility   = Visibility.Visible; cbv1.Width = cbv1w_when_cbv2_is_not_visible;
                    cbv2.Visibility   = Visibility.Hidden; _lbl_2Values_Separator.Visibility = Visibility.Hidden;
                    bPaste.Visibility = Visibility.Visible; bPaste.IsEnabled = true;
                    break;

                default:
                    cbv1.Visibility   = Visibility.Visible; cbv1.Width = cbv1w_when_cbv2_is_not_visible;
                    cbv2.Visibility   = Visibility.Hidden; _lbl_2Values_Separator.Visibility = Visibility.Hidden;
                    bPaste.Visibility = Visibility.Hidden; bPaste.IsEnabled = false;
                    Grid.SetColumnSpan(cbv1, 3);
                    break;
                }
            }
        }