Exemplo n.º 1
0
        public void ToggleSortOrder()
        {
            SortColumnNode sortColumnNode = this.SelectedNode as SortColumnNode;

            if (sortColumnNode != null)
            {
                if (sortColumnNode.SortDirection == ListSortDirection.Ascending)
                {
                    sortColumnNode.SortDirection      = ListSortDirection.Descending;
                    sortColumnNode.ImageIndex         = descendingIcon;
                    sortColumnNode.SelectedImageIndex = descendingIcon;
                }
                else
                {
                    sortColumnNode.SortDirection      = ListSortDirection.Ascending;
                    sortColumnNode.ImageIndex         = ascendingIcon;
                    sortColumnNode.SelectedImageIndex = ascendingIcon;
                }
                SortColumn abstractColumn = null;
                if (this.SelectedNode is GroupColumnNode)
                {
                    abstractColumn = (SortColumn)this.reportModel.ReportSettings.GroupColumnsCollection.Find(this.SelectedNode.Text);
                }
                else
                {
                    abstractColumn = (SortColumn)this.reportModel.ReportSettings.SortColumnsCollection.Find(this.SelectedNode.Text);
                }
                abstractColumn.SortDirection = sortColumnNode.SortDirection;
                this.OnPropertyChanged("ToggleSortOrder");
            }
        }
Exemplo n.º 2
0
        private ColumnCollection CollectSortColumns()
        {
            ColumnCollection cl = new ColumnCollection();

            if (this.nodeSorting.Nodes.Count > 0)
            {
                SortColumn     sortColumn;
                AbstractColumn abstrCol;

                foreach (SortColumnNode sortNode in this.nodeSorting.Nodes)
                {
                    abstrCol = this.reportModel.ReportSettings.AvailableFieldsCollection.Find(sortNode.Text);

                    if (abstrCol != null)
                    {
                        sortColumn = new SortColumn(sortNode.FieldName,
                                                    sortNode.SortDirection,
                                                    abstrCol.DataType, true);
                    }
                    else
                    {
                        sortColumn = new SortColumn(sortNode.Text,
                                                    sortNode.SortDirection,
                                                    typeof(System.String), true);
                    }
                    cl.Add(sortColumn);
                }
            }
            return(cl);
        }
Exemplo n.º 3
0
        //----------------------------------------------------------------------------------------------------------------------------------
        // Query Options
        //----------------------------------------------------------------------------------------------------------------------------------
        public questStatus TransferQueryOptions(QueryOptionsViewModel queryOptionsViewModel, out QueryOptions queryOptions)
        {
            // Initialize
            queryOptions = null;
            QueryOptions qo = new QueryOptions();

            // Transfer model
            foreach (SortColumnViewModel sortColumnViewModel in queryOptionsViewModel.SortColumns.Columns)
            {
                SortColumn sortColumn = new SortColumn();
                sortColumn.Name      = sortColumnViewModel.Name;
                sortColumn.Direction = sortColumnViewModel.Direction == SortDirectionViewModel.DESC ? SortDirection.DESC : SortDirection.ASC;
                qo.SortColumns.Columns.Add(sortColumn);
            }
            BufferMgr.TransferBuffer(queryOptionsViewModel.Paging, qo.Paging);
            qo.SearchOptions.SearchString = queryOptionsViewModel.SearchOptions.SearchString;
            foreach (SearchFieldViewModel searchFieldViewModel in queryOptionsViewModel.SearchOptions.SearchFieldList)
            {
                SearchField searchField = new SearchField();
                searchField.Name            = searchFieldViewModel.Name;
                searchField.Value           = searchFieldViewModel.Value;
                searchField.SearchOperation = convertSearchOperationTypes(searchFieldViewModel.SearchOperation);
                searchField.Type            = convertSearchFieldDataTypes(searchFieldViewModel.Type);
                qo.SearchOptions.SearchFieldList.Add(searchField);
            }

            // Return model
            queryOptions = qo;

            return(new questStatus(Severity.Success));
        }
Exemplo n.º 4
0
		public void DefaultConstructor()
		{
			SortColumn sc = new SortColumn("TestColumn",typeof(System.String));
			Assert.AreEqual(sc.ColumnName,columnName,"ColumnName shoul be equal 'columnName'");
			Assert.AreEqual (typeof(System.String),sc.DataType);
			Assert.AreEqual(System.ComponentModel.ListSortDirection.Ascending,sc.SortDirection);
		}
Exemplo n.º 5
0
        private static ITypeSearch <object> GetSortedSearch(SortColumn sortColumn, ITypeSearch <IFacetContent> query)
        {
            switch (sortColumn.ColumnName)
            {
            case "name":
            {
                return(sortColumn.SortDescending ? query.OrderByDescending(x => x.Name) : query.OrderBy(x => x.Name));
            }

            case "code":
            {
                return(sortColumn.SortDescending ? query.OrderByDescending(x => x.Code) : query.OrderBy(x => x.Code));
            }

            case "startPublish":
            {
                return(sortColumn.SortDescending ? query.OrderByDescending(x => x.StartPublish) : query.OrderBy(x => x.StartPublish));
            }

            case "stopPublish":
            {
                return(sortColumn.SortDescending ? query.OrderByDescending(x => x.StopPublish) : query.OrderBy(x => x.StopPublish));
            }

            case "metaClassName":
            {
                return(sortColumn.SortDescending ? query.OrderByDescending(x => x.MetaClassId) : query.OrderBy(x => x.MetaClassId));
            }

            default:
            {
                return(sortColumn.SortDescending ? query.OrderByDescending(x => x.ContentTypeID) : query.OrderBy(x => x.ContentTypeID));
            }
            }
        }
Exemplo n.º 6
0
        public ISelectStatementBuilder OrderBy(SortColumn sort)
        {
            if (sort != null)
                sortColumns.Add(sort);

            return this;
        }
        public void SortAscendingByTwoColumns()
        {
            SortColumn sc  = new SortColumn("Last", System.ComponentModel.ListSortDirection.Ascending);
            SortColumn sc1 = new SortColumn("RandomInt", System.ComponentModel.ListSortDirection.Ascending);

            ReportSettings rs = new ReportSettings();

            rs.SortColumnCollection.Add(sc);
            rs.SortColumnCollection.Add(sc1);
            IDataManager  dm      = ICSharpCode.Reports.Core.DataManager.CreateInstance(this.contributorCollection, rs);
            DataNavigator dataNav = dm.GetNavigator;
            string        v1      = String.Empty;

            while (dataNav.MoveNext())
            {
                Contributor view = dataNav.Current as Contributor;
                string      v2   = view.Last + "-" + view.RandomInt;
                //string ss = String.Format("< {0} > <{1}>",v1,v2);
                //Console.WriteLine(ss);
                //Console.WriteLine(v2);
                Assert.LessOrEqual(v1, v2);
                v1 = v2;
            }
            Assert.IsTrue(dataNav.IsSorted);
        }
        public void SortByDefaults()
        {
            _prevSortColumn    = _sortColumn;
            _prevSortDirection = _sortDirection;

            SortByColumn(_defaultSortColumn, true);
        }
        private SortColumn UpdateSortColumn(SortColumn column)
        {
            _prevSortColumn = _sortColumn;

            _sortColumn = column;
            return(_sortColumn);
        }
Exemplo n.º 10
0
        ///<summary>Sets the owning edit's DataSource.  This method must be called when initialization is complete.</summary>
        void SetEditorData()
        {
            if (IsLoading || OwnerEdit == null || OwnerEdit.BindingContext == null)
            {
                return;
            }
            if (DataSource == null)
            {
                OwnerEdit.AllItems = new object[0];
                return;
            }

            ResultsBindingManager = OwnerEdit.BindingContext[DataSource, DataMember];
            ItemProperties        = ResultsBindingManager.GetItemProperties();
            OwnerEdit.AllItems    = (IList)ListBindingHelper.GetList(DataSource, DataMember);
            Columns.OnDataSourceSet();
            AdditionalResultColumns.OnDataSourceSet();
            if (ResultDisplayColumn != null)
            {
                ResultDisplayColumn.SetOwner(this);
            }
            if (SortColumn != null)
            {
                SortColumn.SetOwner(this);
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// Perform a search of the two tasks based on the
        /// SortColumn specified.
        /// </summary>
        int CompareTasks(Task a, Task b, SortColumn sort_type)
        {
            if (a == null)
            {
                return(-1);
            }
            if (b == null)
            {
                return(1);
            }

            try {
                switch (sort_column)
                {
                case SortColumn.CompletionDate:
                    return(DateTime.Compare(a.CompletionDate, b.CompletionDate));

                case SortColumn.DueDate:
                    return(DateTime.Compare(a.DueDate, b.DueDate));

//    case SortColumn.OriginNote:
//     return a.OriginNoteUri.CompareTo (b.OriginNoteUri);
                case SortColumn.Priority:
                    return((int)a.Priority - (int)b.Priority);

                case SortColumn.Summary:
                    return(a.Summary.CompareTo(b.Summary));
                }
            } catch (Exception e) {
                Logger.Warn("Exception in TaskListWindow.CompareTasks ({0}): {1}",
                            sort_type, e.Message);
            }

            return(-1);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Excecutes the search result using EF
        /// </summary>
        /// <param name="name"></param>
        /// <param name="groupName"></param>
        /// <param name="pageNumber"></param>
        /// <param name="pageSize"></param>
        /// <param name="sortColumn"></param>
        /// <param name="sortOrder"></param>
        /// <returns></returns>
        public async Task <List <SearchResultDto> > GetSearchResultUsingEFCore(string name,
                                                                               string groupName,
                                                                               int pageNumber        = 1,
                                                                               int pageSize          = 100,
                                                                               SortColumn sortColumn = SortColumn.DateAdded,
                                                                               SortOrder sortOrder   = SortOrder.Asc)
        {
            var person = from p in _context.Person.Include(p => p.Group)
                         select p;


            if (!string.IsNullOrWhiteSpace(name))
            {
                name   = $"%{name.ToLower()}%";
                person = from p in person
                         where EF.Functions.Like(p.Name.ToLower(), name)
                         select p;
            }

            if (!string.IsNullOrWhiteSpace(groupName))//can restrict user to send group id only
            {
                groupName = $"%{groupName.ToLower()}%";
                person    = from p in person
                            where EF.Functions.Like(p.Group.Name.ToLower(), groupName)
                            select p;
            }

            if (sortColumn == SortColumn.DateAdded && sortOrder == SortOrder.Asc)
            {
                person.OrderBy(p => p.Name).ThenBy(p => p.Group);
            }

            if (sortColumn == SortColumn.Group && sortOrder == SortOrder.Asc)
            {
                person.OrderBy(p => p.Group).ThenBy(p => p.Name);
            }

            if (sortColumn == SortColumn.DateAdded && sortOrder == SortOrder.Desc)
            {
                person.OrderByDescending(p => p.Group).ThenBy(p => p.Name);
            }

            if (sortColumn == SortColumn.Group && sortOrder == SortOrder.Desc)
            {
                person.OrderByDescending(p => p.Group).ThenBy(p => p.Name);
            }


            return(await person.Skip(pageSize *(pageNumber - 1))
                   .Take(pageSize)
                   .Select(p => new SearchResultDto()
            {
                Id = p.Id,
                Name = p.Name,
                DateAdded = p.DateAdded,
                GroupId = p.GroupId,
                GroupName = p.Group.Name
            }).ToListAsync());
        }
Exemplo n.º 13
0
        public void TableStrategy_Set_IsSorted()
        {
            SortColumn sc            = new SortColumn("Last", System.ComponentModel.ListSortDirection.Ascending);
            var        tableStrategy = SortTableStrategyFactory(sc);

            tableStrategy.Bind();
            Assert.That(tableStrategy.IsSorted == true);
        }
Exemplo n.º 14
0
 public SqliteStorageOptions(string connectionString, string schemaName = null, string tableName = null,
                             string tableNamePrefix       = null, string tableNameSuffix = null, bool useTransactions = false,
                             bool bufferedLoad            = false, int defaultTakeSize   = 1000, int maxTakeSize      = 5000, bool enableLogging = true,
                             SortColumn defaultSortColumn = SortColumn.Id)
     : base(connectionString, schemaName: schemaName, tableName: tableName, tableNamePrefix: tableNamePrefix, tableNameSuffix: tableNameSuffix, useTransactions: useTransactions, bufferedLoad: bufferedLoad,
            defaultTakeSize: defaultTakeSize, maxTakeSize: maxTakeSize, enableLogging: enableLogging, defaultSortColumn: defaultSortColumn)
 {
 }
Exemplo n.º 15
0
        public void DefaultConstructor()
        {
            SortColumn sc = new SortColumn("TestColumn", typeof(System.String));

            Assert.AreEqual(sc.ColumnName, columnName, "ColumnName shoul be equal 'columnName'");
            Assert.AreEqual(typeof(System.String), sc.DataType);
            Assert.AreEqual(System.ComponentModel.ListSortDirection.Ascending, sc.SortDirection);
        }
Exemplo n.º 16
0
        private TableStrategy SortTableStrategyFactory(SortColumn sortColumn)
        {
            var reportSettings = new ReportSettings();

            reportSettings.SortColumnsCollection.Add(sortColumn);
            var tableStrategy = new TableStrategy(this.table, reportSettings);

            return(tableStrategy);
        }
        public ISelectStatementBuilder OrderBy(SortColumn sort)
        {
            if (sort != null)
            {
                sortColumns.Add(sort);
            }

            return(this);
        }
        public void ColumnNotExistThrow()
        {
            SortColumn     sc = new SortColumn("notexist", System.ComponentModel.ListSortDirection.Ascending);
            ReportSettings rs = new ReportSettings();

            rs.SortColumnsCollection.Add(sc);
            IDataManager  dm      = ICSharpCode.Reports.Core.DataManager.CreateInstance(this.table, rs);
            DataNavigator dataNav = dm.GetNavigator;
        }
Exemplo n.º 19
0
        public void SortChildrenDescending()
        {
            ReportSettings rs = new ReportSettings();
            GroupColumn    gc = new GroupColumn("GroupItem", 1, ListSortDirection.Ascending);

            rs.GroupColumnsCollection.Add(gc);

            SortColumn sc = new SortColumn("Last", ListSortDirection.Descending);

            rs.SortColumnsCollection.Add(sc);
            IDataManager dm            = ICSharpCode.Reports.Core.DataManager.CreateInstance(this.contributorCollection, rs);
            var          dataNavigator = dm.GetNavigator;

            ReportItemCollection searchCol = new ReportItemCollection();

            searchCol.Add(new BaseDataItem()
            {
                Name       = "Last",
                ColumnName = "Last"
            }
                          );

            searchCol.Add(new BaseDataItem()
            {
                ColumnName = "GroupItem"
            }
                          );

            string compare = String.Empty;

            while (dataNavigator.MoveNext())
            {
                dataNavigator.Fill(searchCol);
                var column = (BaseDataItem)searchCol[1];
                var result = column.DBValue.ToString();

                Assert.That(compare, Is.LessThan(result));
                if (dataNavigator.HasChildren)
                {
                    string compareChild   = String.Empty;
                    var    childNavigator = dataNavigator.GetChildNavigator;
                    do
                    {
                        childNavigator.Fill(searchCol);
                        var childColumn = (BaseDataItem)searchCol[0];
                        var childResult = childColumn.DBValue.ToString();
//						Console.WriteLine("\t{0}",childResult);
                        if (!String.IsNullOrEmpty(compareChild))
                        {
                            Assert.LessOrEqual(childResult, compareChild);
                        }
                        compareChild = childResult;
                    }while (childNavigator.MoveNext());
                }
            }
        }
Exemplo n.º 20
0
        private void View_SortAttributes(object sender, SortEventArgs e)
        {
            if (_attributes.IsSelectionEmpty)
            {
                return;
            }

            // remove the last row temporarily
            var lastRow = View.Attributes[View.Attributes.Count - 1];

            if (IsEditingEnabled)
            {
                View.Attributes.RemoveAt(View.Attributes.Count - 1);
            }

            // determine sort column and direction
            _currentSortColumn = e.Column;
            if (e.Column != SortColumn.None)
            {
                if (_currentSortColumn != e.Column || _currentSortDirection == SortDirection.Descending)
                {
                    _currentSortDirection = SortDirection.Ascending;
                }
                else
                {
                    _currentSortDirection = SortDirection.Descending;
                }
            }

            // sort the values
            IComparer <AttributeGroup> comparer;

            if (e.Column == SortColumn.Name)
            {
                comparer = CreateComparer(attr => attr.Value.Name, (int)_currentSortDirection);
            }
            else if (e.Column == SortColumn.Type)
            {
                comparer = CreateComparer(attr => attr.Value.Value.Type, (int)_currentSortDirection);
            }
            else // if (e.Column == SortColumn.Value)
            {
                comparer = Comparer <AttributeGroup> .Create((a, b) =>
                                                             (int)_currentSortDirection *
                                                             ValueComparer.Default.Compare(a.Value.Value, b.Value.Value));
            }
            View.Attributes.Sort(comparer);

            // add back the last row and update the view
            if (IsEditingEnabled)
            {
                View.Attributes.Add(lastRow);
            }

            View.UpdateAttributes();
        }
Exemplo n.º 21
0
 ///<summary>
 ///Serves as a hash function for a particular type.
 ///</summary>
 ///
 ///<returns>
 ///A hash code for the current <see cref="T:System.Object" />.
 ///</returns>
 ///<filterpriority>2</filterpriority>
 public override int GetHashCode()
 {
     unchecked
     {
         int result = (_list != null ? _list.GetHashCode() : 0);
         result = (result * 397) ^ (SortColumn != null ? SortColumn.GetHashCode() : 0);
         result = (result * 397) ^ (FilterDef != null ? FilterDef.GetHashCode() : 0);
         return(result);
     }
 }
Exemplo n.º 22
0
		public void Constr_2 ()
		{
			SortColumn sc = new SortColumn ("TestColumn",
			                                ListSortDirection.Descending);
			Assert.AreEqual(columnName,sc.ColumnName,"ColumnName should be equal 'columnName'");
			Assert.AreEqual(ListSortDirection.Descending,
			                sc.SortDirection,"SortDirection shoul be Descending");
			Type t = typeof(System.String);
			Assert.AreEqual(t,sc.DataType,"Type should be 'String'");
		}
        public void SortColumCollection_Sorting_Should_Set()
        {
            ReportModel m  = ReportGenerationHelper.CreateModel(reportName, false);
            var         rs = m.ReportSettings;

            SortColumn gc = new SortColumn("GroupItem", ListSortDirection.Ascending);

            rs.SortColumnsCollection.Add(gc);

            Assert.AreEqual(rs.SortColumnsCollection.Count, 1);
        }
Exemplo n.º 24
0
        /// <summary>
        /// Raised when the user clicks a column header.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void listView_ColumnClick(object sender, ColumnClickEventArgs e)
        {
            SortColumn   sortColumn = _Sorter.SortColumn;
            ColumnHeader header     = listView.Columns[e.Column];

            if (header == columnHeaderBytesSent)
            {
                sortColumn = SortColumn.BytesSent;
            }
            else if (header == columnHeaderCountSessions)
            {
                sortColumn = SortColumn.Sessions;
            }
            else if (header == columnHeaderDuration)
            {
                sortColumn = SortColumn.Duration;
            }
            else if (header == columnHeaderFirstSeen)
            {
                sortColumn = SortColumn.FirstSeen;
            }
            else if (header == columnHeaderIpAddress)
            {
                sortColumn = SortColumn.IpAddress;
            }
            else if (header == columnHeaderLastSeen)
            {
                sortColumn = SortColumn.LastSeen;
            }
            else if (header == columnHeaderSource)
            {
                sortColumn = SortColumn.IsLocal;
            }
            else if (header == columnHeaderReverseDns)
            {
                sortColumn = SortColumn.ReverseDns;
            }
            else
            {
                throw new NotImplementedException();
            }

            if (sortColumn == _Sorter.SortColumn)
            {
                _Sorter.Ascending = !_Sorter.Ascending;
            }
            else
            {
                _Sorter.SortColumn = sortColumn;
                _Sorter.Ascending  = true;
            }

            listView.Sort();
        }
Exemplo n.º 25
0
 public override int GetHashCode()
 {
     unchecked
     {
         int result = Page;
         result = (result * 397) ^ ResultsPerPage;
         result = (result * 397) ^ (SortColumn != null ? SortColumn.GetHashCode() : 0);
         result = (result * 397) ^ SortAscending.GetHashCode();
         return(result);
     }
 }
Exemplo n.º 26
0
        public void Constr_2()
        {
            SortColumn sc = new SortColumn("TestColumn",
                                           ListSortDirection.Descending);

            Assert.AreEqual(columnName, sc.ColumnName, "ColumnName should be equal 'columnName'");
            Assert.AreEqual(ListSortDirection.Descending,
                            sc.SortDirection, "SortDirection shoul be Descending");
            Type t = typeof(System.String);

            Assert.AreEqual(t, sc.DataType, "Type should be 'String'");
        }
Exemplo n.º 27
0
        public void Sort(int columnIndex)
        {
            if (treeDataGridView.RowCount == 0)
            {
                return;
            }

            SortColumn sortColumn;

            // if already sorting by the clicked column, reverse sort order
            if (sortColumns.Any(o => o.Index == columnIndex))
            {
                int index = sortColumns.FindIndex(o => o.Index == columnIndex);
                sortColumn = sortColumns[index];
                sortColumn.ToggleOrder();
            }
            else
            {
                //if (e.Button == MouseButtons.Left)
                {
                    foreach (var c in sortColumns)
                    {
                        treeDataGridView.Columns[c.Index].HeaderCell.SortGlyphDirection = SortOrder.None;
                    }
                    sortColumns.Clear();
                }
                //else if (e.Button != MouseButtons.Middle)
                //    return;
                if (initialColumnSortOrders.Contains(columnIndex))
                {
                    sortColumn = new SortColumn()
                    {
                        Index = columnIndex, Order = initialColumnSortOrders[columnIndex]
                    }
                }
                ;
                else
                {
                    sortColumn = new SortColumn()
                    {
                        Index = columnIndex, Order = SortOrder.Descending
                    }
                };
            }

            var column = treeDataGridView.Columns[columnIndex];

            column.HeaderCell.SortGlyphDirection = sortColumn.Order;
            sortColumns.Add(sortColumn);
            applySort();
            treeDataGridView.CollapseAll();
            treeDataGridView.Refresh();
        }
Exemplo n.º 28
0
		public void CanSort_String_Ascending()
		{
			SortColumn sc = new SortColumn("Last",System.ComponentModel.ListSortDirection.Ascending);
			var tableStrategy = SortTableStrategyFactory(sc);
			tableStrategy.Bind();
			string v1 = String.Empty;
			foreach (BaseComparer element in tableStrategy.IndexList) {
				string v2 = element.ObjectArray[0].ToString();
				Assert.LessOrEqual(v1,v2);
				v1 = v2;
			}
		}
Exemplo n.º 29
0
		public void Constr_3 ()
		{
			SortColumn sc = new SortColumn ("TestColumn",
			                                ListSortDirection.Ascending,typeof(System.String),true);
			Assert.AreEqual(columnName,
			                sc.ColumnName,
			                "ColumnName should be equal 'columnName'");
			Assert.AreEqual(ListSortDirection.Ascending,
			                sc.SortDirection,"SortDirection shoul be Aescending");
			Type t = typeof(System.String);
			Assert.AreEqual(t,sc.DataType,"Type should be 'String'");
			Assert.IsTrue(sc.CaseSensitive);
		}
Exemplo n.º 30
0
        public IQueryable <File> Search(string Query, HashSet <int> watchers, SortColumn order)
        {
            var result = from file in
                         Files.FromSqlRaw(
                "SELECT *" +
                "FROM \"Files\" WHERE \"Id\" IN (" +
                "SELECT RowID from FileFTS WHERE FileFTS MATCH {0}" +
                ")"
                , Query).AsNoTracking()
                         where watchers.Contains(file.WatcherId)
                         select file;

            return(OrderBySort(result, order));
        }
Exemplo n.º 31
0
        private void Delete_Click(object sender, EventArgs e)
        {
            GetColumns();
            int ci = SelectedCol;

            if (ci < 0 || ci >= Columns.Count)
            {
                return;
            }
            SortColumn sc = Columns[ci];

            Columns.RemoveAt(ci);
            Setup();
            SelectCol(ci);
        }
Exemplo n.º 32
0
        /// <summary>
        /// Called when the user clicks a column header.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void listView_ColumnClick(object sender, ColumnClickEventArgs e)
        {
            SortColumn sortColumn = ColumnIndexToSortColumn(e.Column);

            if (_Sorter.SortColumn == sortColumn)
            {
                _Sorter.SortAscending = !_Sorter.SortAscending;
            }
            else
            {
                _Sorter.SortColumn    = sortColumn;
                _Sorter.SortAscending = true;
            }
            Sort();
        }
Exemplo n.º 33
0
        public void CanSort_DateTime_Descending()
        {
            SortColumn sc = new SortColumn("RandomDate", System.ComponentModel.ListSortDirection.Descending,
                                           typeof(System.Int16), false);

            var      tableStrategy = SortTableStrategyFactory(sc);
            DateTime d1            = new DateTime(1, 1, 1);

            foreach (BaseComparer element in tableStrategy.IndexList)
            {
                DateTime d2 = Convert.ToDateTime(element.ObjectArray[0].ToString());
                Assert.GreaterOrEqual(d1, d2);
                d1 = d2;
            }
        }
Exemplo n.º 34
0
        public void Constr_3()
        {
            SortColumn sc = new SortColumn("TestColumn",
                                           ListSortDirection.Ascending, typeof(System.String), true);

            Assert.AreEqual(columnName,
                            sc.ColumnName,
                            "ColumnName should be equal 'columnName'");
            Assert.AreEqual(ListSortDirection.Ascending,
                            sc.SortDirection, "SortDirection shoul be Aescending");
            Type t = typeof(System.String);

            Assert.AreEqual(t, sc.DataType, "Type should be 'String'");
            Assert.IsTrue(sc.CaseSensitive);
        }
Exemplo n.º 35
0
        public void CanSort_String_Ascending()
        {
            SortColumn sc            = new SortColumn("Last", System.ComponentModel.ListSortDirection.Ascending);
            var        tableStrategy = SortTableStrategyFactory(sc);

            tableStrategy.Bind();
            string v1 = String.Empty;

            foreach (BaseComparer element in tableStrategy.IndexList)
            {
                string v2 = element.ObjectArray[0].ToString();
                Assert.LessOrEqual(v1, v2);
                v1 = v2;
            }
        }
Exemplo n.º 36
0
		public void CanSort_DateTime_Ascending()
		{
			SortColumn sc = new SortColumn("RandomDate",System.ComponentModel.ListSortDirection.Ascending,
			                               typeof(System.Int16),false);

			var tableStrategy =SortTableStrategyFactory (sc);
		
			DateTime d1 = new DateTime(1,1,1);
			
			foreach (BaseComparer element in tableStrategy.IndexList) {

				DateTime d2 = Convert.ToDateTime(element.ObjectArray[0].ToString());
				Assert.LessOrEqual(d1,d2);
				d1 = d2;
			}
		}
Exemplo n.º 37
0
		/// <summary>
		/// Handle the click of the specified column by setting the
		/// sort_column and adjusting the sort type (ascending/descending).
		/// </summary>
		void OnColumnClicked (Gtk.TreeViewColumn column, SortColumn column_type)
		{
			if (sort_column != column_type) {
				sort_column = column_type;
			} else {
				if (column.SortOrder == Gtk.SortType.Ascending)
					column.SortOrder = Gtk.SortType.Descending;
				else
					column.SortOrder = Gtk.SortType.Ascending;
			}

			// Set up the sort function again so the tree is resorted
			// Is there a better way to do this?
			store_sort.ResetDefaultSortFunc ();
			store_sort.DefaultSortFunc =
			        new Gtk.TreeIterCompareFunc (TaskSortFunc);
		}
Exemplo n.º 38
0
		/// <summary>
		/// Perform a search of the two tasks based on the
		/// SortColumn specified.
		/// </summary>
		int CompareTasks (Task a, Task b, SortColumn sort_type)
		{
			if (a == null)
				return -1;
			if (b == null)
				return 1;

			try {
				switch (sort_column) {
				case SortColumn.CompletionDate:
					return DateTime.Compare (a.CompletionDate, b.CompletionDate);
				case SortColumn.DueDate:
					return DateTime.Compare (a.DueDate, b.DueDate);
//    case SortColumn.OriginNote:
//     return a.OriginNoteUri.CompareTo (b.OriginNoteUri);
				case SortColumn.Priority:
					return (int) a.Priority - (int) b.Priority;
				case SortColumn.Summary:
					return a.Summary.CompareTo (b.Summary);
				}
			} catch (Exception e) {
				Logger.Warn ("Exception in TaskListWindow.CompareTasks ({0}): {1}",
				             sort_type, e.Message);
			}

			return -1;
		}
Exemplo n.º 39
0
        private static IList<SortColumn> ResolveOrderByRefs(PreparedQuerySelectColumns columnSet,
			IEnumerable<SortColumn> orderBy)
        {
            // Resolve any numerical references in the ORDER BY list (eg.
            // '1' will be a reference to column 1.
            if (orderBy == null)
                return null;

            var columnCount = columnSet.SelectedColumns.Count();

            var resolvedColumns = new List<SortColumn>();
            foreach (var column in orderBy) {
                var resolved = column;

                var expression = column.Expression;
                if (expression.ExpressionType == SqlExpressionType.Constant) {
                    var value = ((SqlConstantExpression) expression).Value;
                    if (value.Type is NumericType &&
                        !value.IsNull) {
                        var colRef = ((SqlNumber) value.Value).ToInt32() - 1;
                        if (colRef >= 0 && colRef < columnCount) {
                            var funArray = columnSet.FunctionColumns.ToArray();
                            var refExp = funArray[colRef];

                            resolved = new SortColumn(refExp.Expression, column.Ascending);
                        }
                    }
                }

                resolvedColumns.Add(resolved);
            }

            return resolvedColumns.ToArray();
        }
Exemplo n.º 40
0
		private ICSharpCode.Reports.Core.ListStrategy.TableStrategy SortTableStrategyFactory (SortColumn sortColumn)
		{
			var reportSettings = new ReportSettings();
			reportSettings.SortColumnsCollection.Add(sortColumn);
			var tableStrategy = new ICSharpCode.Reports.Core.ListStrategy.TableStrategy(this.table,reportSettings);
			return tableStrategy;
		}
Exemplo n.º 41
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="data"></param>
 public SortLogic(Info data)
 {
     Column = data.SortColumn;
     if (data.direction == ListSortDirection.Ascending) Direction = 1;
     else Direction = -1;
 }
Exemplo n.º 42
0
		public void CanSort_Ascending_By_TwoColumns()
		{
			SortColumn sc = new SortColumn("Last",System.ComponentModel.ListSortDirection.Ascending);
			SortColumn sc1 = new SortColumn("RandomInt",System.ComponentModel.ListSortDirection.Ascending);
			
			ReportSettings reportSettings = new ReportSettings();
			reportSettings.SortColumnsCollection.Add(sc);
			reportSettings.SortColumnsCollection.Add(sc1);
			
			var tableStrategy = new ICSharpCode.Reports.Core.ListStrategy.TableStrategy(this.table,reportSettings);
			string v1 = String.Empty;
			
			foreach (BaseComparer element in tableStrategy.IndexList) {
				string v2 = element.ObjectArray[0].ToString();
				Assert.LessOrEqual(v1,v2);
				v1 = v2;
			}
		}
Exemplo n.º 43
0
		public void SortChildrenDescending()
		{
			ReportSettings rs = new ReportSettings();
			GroupColumn gc = new GroupColumn("GroupItem",1,ListSortDirection.Ascending);
			rs.GroupColumnsCollection.Add(gc);
			
			SortColumn sc = new SortColumn("Last",ListSortDirection.Descending);
			rs.SortColumnsCollection.Add(sc);
			IDataManager dm = ICSharpCode.Reports.Core.DataManager.CreateInstance(this.contributorCollection,rs);
			var dataNavigator = dm.GetNavigator;
			
			ReportItemCollection searchCol = new ReportItemCollection();
			searchCol.Add(new BaseDataItem ()
			              {
			              	Name ="Last",
			              	ColumnName ="Last"
			              }
			             );
			
			searchCol.Add(new BaseDataItem ()
			              {
			              	
			              	ColumnName ="GroupItem"
			              }
			             );
			
			string compare = String.Empty;

			while (dataNavigator.MoveNext())
			{
				dataNavigator.Fill(searchCol);
				var column = (BaseDataItem)searchCol[1];
				var result = column.DBValue.ToString();
				
				Assert.That (compare,Is.LessThan(result));
				if (dataNavigator.HasChildren) {
					string compareChild = String.Empty;
					var childNavigator = dataNavigator.GetChildNavigator;
					do
					{
						childNavigator.Fill(searchCol);
						var childColumn = (BaseDataItem)searchCol[0];
						var childResult = childColumn.DBValue.ToString();
//						Console.WriteLine("\t{0}",childResult);
						if (!String.IsNullOrEmpty(compareChild)) {
							Assert.LessOrEqual(childResult,compareChild);
						}
						compareChild = childResult;
					}
					while (childNavigator.MoveNext());
				}
			}
		}
Exemplo n.º 44
0
        public void Sort (int columnIndex)
        {
            SortColumn sortColumn;

            // if already sorting by the clicked column, reverse sort order
            if (sortColumns.Any(o => o.Index == columnIndex))
            {
                int index = sortColumns.FindIndex(o => o.Index == columnIndex);
                sortColumn = sortColumns[index];
                sortColumn.ToggleOrder();
            }
            else
            {
                //if (e.Button == MouseButtons.Left)
                {
                    foreach (var c in sortColumns)
                        treeDataGridView.Columns[c.Index].HeaderCell.SortGlyphDirection = SortOrder.None;
                    sortColumns.Clear();
                }
                //else if (e.Button != MouseButtons.Middle)
                //    return;
                if (initialColumnSortOrders.Contains(columnIndex))
                    sortColumn = new SortColumn() { Index = columnIndex, Order = initialColumnSortOrders[columnIndex] };
                else
                    sortColumn = new SortColumn() { Index = columnIndex, Order = SortOrder.Descending };
            }

            var column = treeDataGridView.Columns[columnIndex];
            column.HeaderCell.SortGlyphDirection = sortColumn.Order;
            sortColumns.Add(sortColumn);
            applySort();
            treeDataGridView.CollapseAll();
            treeDataGridView.Refresh();
        }
Exemplo n.º 45
0
		protected TaskListWindow (TaskManager manager)
: base (Catalog.GetString ("To Do List"))
		{
			this.manager = manager;
			this.IconName = "tomboy";
			this.SetDefaultSize (500, 300);
			this.sort_column = SortColumn.CompletionDate;

			AddAccelGroup (Tomboy.ActionManager.UI.AccelGroup);

			action_group = new Gtk.ActionGroup ("TaskList");
			action_group.Add (new Gtk.ActionEntry [] {
				new Gtk.ActionEntry ("TaskListFileMenuAction", null,
				Catalog.GetString ("_File"), null, null, null),

				new Gtk.ActionEntry ("NewTaskAction", Gtk.Stock.New,
				Catalog.GetString ("New _Task"), "<Control>T",
				Catalog.GetString ("Create a new task"), null),

				new Gtk.ActionEntry ("OpenTaskAction", String.Empty,
				Catalog.GetString ("_Options..."), "<Control>O",
				Catalog.GetString ("Open the selected task"), null),

				new Gtk.ActionEntry ("CloseTaskListWindowAction", Gtk.Stock.Close,
				Catalog.GetString ("_Close"), "<Control>W",
				Catalog.GetString ("Close this window"), null),

				new Gtk.ActionEntry ("TaskListEditMenuAction", null,
				Catalog.GetString ("_Edit"), null, null, null),

				new Gtk.ActionEntry ("DeleteTaskAction", Gtk.Stock.Preferences,
				Catalog.GetString ("_Delete"), "Delete",
				Catalog.GetString ("Delete the selected task"), null),

				new Gtk.ActionEntry ("OpenOriginNoteAction", null,
				Catalog.GetString ("Open Associated _Note"), null,
				Catalog.GetString ("Open the note containing the task"), null),

				new Gtk.ActionEntry ("TaskListViewMenuAction", null,
				Catalog.GetString ("_View"), null, null, null),

				new Gtk.ActionEntry ("TaskListHelpMenuAction", null,
				Catalog.GetString ("_Help"), null, null, null),

				new Gtk.ActionEntry ("ShowTaskHelpAction", Gtk.Stock.Help,
				Catalog.GetString ("_Contents"), "F1",
				Catalog.GetString ("Tasks Help"), null)
			});

			action_group.Add (new Gtk.ToggleActionEntry [] {
				new Gtk.ToggleActionEntry ("ShowCompletedTasksAction", null,
				Catalog.GetString ("Show _Completed Tasks"), null,
				Catalog.GetString ("Show completed tasks in the list"), null, true),

				new Gtk.ToggleActionEntry ("ShowDueDateColumnAction", null,
				Catalog.GetString ("Show _Due Date Column"), null,
				Catalog.GetString ("Show the due date column in the list"), null, true),

				new Gtk.ToggleActionEntry ("ShowPriorityColumnAction", null,
				Catalog.GetString ("Show _Priority Column"), null,
				Catalog.GetString ("Show the priority column in the list"), null, true)
			});

			Tomboy.ActionManager.UI.InsertActionGroup (action_group, 0);

			menu_bar = CreateMenuBar ();

			MakeTasksTree ();
			tree.Show ();

			// Update on changes to tasks
			TaskManager.TaskAdded += OnTaskAdded;
			TaskManager.TaskDeleted += OnTaskDeleted;
			TaskManager.TaskStatusChanged += OnTaskStatusChanged;

			tasks_sw = new Gtk.ScrolledWindow ();
			tasks_sw.ShadowType = Gtk.ShadowType.In;
			tasks_sw.VscrollbarPolicy = Gtk.PolicyType.Automatic;
			tasks_sw.HscrollbarPolicy = Gtk.PolicyType.Automatic;

			// Reign in the window size if there are notes with long
			// names, or a lot of notes...

			Gtk.Requisition tree_req = tree.SizeRequest ();
			if (tree_req.Height > 420)
				tasks_sw.HeightRequest = 420;

			if (tree_req.Width > 480)
				tasks_sw.WidthRequest = 480;

			tasks_sw.Add (tree);
			tasks_sw.Show ();

			task_count = new Gtk.Label ();
			task_count.Xalign = 0;
			task_count.Show ();

			Gtk.HBox status_box = new Gtk.HBox (false, 8);
			status_box.PackStart (task_count, true, true, 0);
			status_box.Show ();

			Gtk.VBox vbox = new Gtk.VBox (false, 8);
			vbox.BorderWidth = 6;
			vbox.PackStart (tasks_sw, true, true, 0);
			vbox.PackStart (status_box, false, false, 0);
			vbox.Show ();

			// Use another VBox to place the MenuBar
			// right at thetop of the window.
			content_vbox = new Gtk.VBox (false, 0);
			content_vbox.PackStart (menu_bar, false, false, 0);
			content_vbox.PackStart (vbox, true, true, 0);
			content_vbox.Show ();

			this.Add (content_vbox);
			this.DeleteEvent += OnDelete;
			this.KeyPressEvent += OnKeyPressed; // For Escape

			SetUpTreeModel ();
		}
Exemplo n.º 46
0
		public void SortChildrenDescending()
		{
			ReportSettings rs = new ReportSettings();
			GroupColumn gc = new GroupColumn("GroupItem",1,ListSortDirection.Ascending);
			rs.GroupColumnsCollection.Add(gc);
			
			SortColumn sc = new SortColumn("Last",ListSortDirection.Descending);
			rs.SortColumnsCollection.Add(sc);
			IDataManager dm = ICSharpCode.Reports.Core.DataManager.CreateInstance(this.table,rs);
			var dataNavigator = dm.GetNavigator;
			
			string compare = String.Empty;
			
			while (dataNavigator.MoveNext())
			{
				DataRow dr = dataNavigator.Current as DataRow;
				var result = dr[3].ToString();
				Assert.That(compare,Is.LessThan(result));
				if (dataNavigator.HasChildren)
				{
					string compareChild = String.Empty;
					var childNavigator = dataNavigator.GetChildNavigator;
					do
					{
						DataRow childRow = childNavigator.Current as DataRow;
						var childResult = childRow[1].ToString();
						if (!String.IsNullOrEmpty(compareChild)) {
							Assert.LessOrEqual(childResult,compareChild);
						}
//						Console.WriteLine("\t{0}",childResult);
						compareChild = childResult;
					}
					while (childNavigator.MoveNext());
				}
				compare = result;
			}
		}