Esempio n. 1
0
        public AdvancedFilter(string filePath, string tablename, string uniqueColumnName, IEnumerable <long> uniqueRowIDs = null)
        {
            InitializeComponent();
            _filePath            = filePath;
            TableName            = tablename;
            SelectedKeys         = uniqueRowIDs;
            _selectionColumnName = uniqueColumnName;

            //handle events from the various specialized components
            TestWindow.ErrorsFound       += ErrorsFound;
            TestWindow.ParseSuccess      += DisplayResult;
            AvailableFunctions.TextToAdd += TextToInsert;
            //assign the proper grid alignment to the textblock that is behaving like a tooltip.
            Grid.SetRow(TestWindow.TextBlock, 3);
            MainGrid.Children.Add(TestWindow.TextBlock);
            //Add the names of the columns to populate the available columns array. (this is currently handled
            Database.Reader.SqLiteReader reader = new Database.Reader.SqLiteReader(filePath, tablename);
            _headers = reader.ColumnNames().ToList();
            TestWindow.SetHeaders = _headers;
            //Add the types of the columns to enforce type strictness.
            List <Type> headertypes = reader.ColumnTypes().ToList();

            TestWindow.SetHeaderTypes = headertypes;
            //Add the first row of data to the database as an object array so that the result will show the result for the first row.
            reader.Open();
            _FirstRow = reader.Row(0);
            if (_selectedKeys != null)
            {
                if (_selectedKeys.Count() > 0)
                {
                    AllowSelectionOption = true;
                    object[] tmp = reader.Column(_selectionColumnName);
                    _FirstSelectedRow = reader.Row(Array.IndexOf(tmp, _selectedKeys.First()));
                }
            }
            _totalRows = reader.RowCount();
            NotifyPropertyChanged(nameof(SelectedCount));
            reader.Close();
            TestWindow.SetDataForFirstRow = _FirstRow;
            //To create a selection, set the output type to boolean...
            TestWindow.SetOutputType = FieldCalculationParser.TypeEnum.Bool;
            ColumnType = "True or False";
            //Add the headers to the avaialblefields treeview. (i am adding type as a tooltip for reference)
            for (int i = 0; i < _headers.Count(); i++)
            {
                System.Windows.Controls.TreeViewItem tvi = new TreeViewItem();
                tvi.Header = _headers[i];
                System.Windows.Controls.ToolTip t = new System.Windows.Controls.ToolTip();
                t.Content   = headertypes[i].Name;
                tvi.ToolTip = t;
                AvailableFields.Items.Add(tvi);
            }
        }
 public void SetColumnNames(string path, string tablename)
 {
     Database.Reader.SqLiteReader reader = new Database.Reader.SqLiteReader(path, tablename);
     ColumnNames = reader.ColumnNames().ToList();
 }