57 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			57 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			C#
		
	
	
	
using System;
 | 
						|
using System.Collections.Generic;
 | 
						|
using System.Globalization;
 | 
						|
using System.Linq;
 | 
						|
using System.Text;
 | 
						|
using System.Threading.Tasks;
 | 
						|
using System.Windows.Data;
 | 
						|
 | 
						|
namespace DM_Weight.Converter
 | 
						|
{
 | 
						|
    public class PaginationConverter : IMultiValueConverter
 | 
						|
    {
 | 
						|
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
 | 
						|
        {
 | 
						|
            string type = values[0].ToString();
 | 
						|
 | 
						|
            if (!string.IsNullOrEmpty(type) && "First".Equals(type))
 | 
						|
            {
 | 
						|
                int CurrentPage = int.Parse(values[1].ToString());
 | 
						|
                return CurrentPage > 1;
 | 
						|
            }
 | 
						|
            if (!string.IsNullOrEmpty(type) && "Prve".Equals(type))
 | 
						|
            {
 | 
						|
                int CurrentPage = int.Parse(values[1].ToString());
 | 
						|
                return CurrentPage > 1;
 | 
						|
            }
 | 
						|
            if (!string.IsNullOrEmpty(type) && "Next".Equals(type))
 | 
						|
            {
 | 
						|
                int CurrentPage = int.Parse(values[1].ToString());
 | 
						|
                int PageCount = int.Parse(values[2].ToString());
 | 
						|
                return PageCount > CurrentPage;
 | 
						|
            }
 | 
						|
            if (!string.IsNullOrEmpty(type) && "End".Equals(type))
 | 
						|
            {
 | 
						|
                int CurrentPage = int.Parse(values[1].ToString());
 | 
						|
                int PageCount = int.Parse(values[2].ToString());
 | 
						|
                return PageCount > CurrentPage;
 | 
						|
            }
 | 
						|
            if (!string.IsNullOrEmpty(type) && "InfoText".Equals(type))
 | 
						|
            {
 | 
						|
                int CurrentPage = int.Parse(values[1].ToString());
 | 
						|
                int PageCount = int.Parse(values[2].ToString());
 | 
						|
                int PageSize = int.Parse(values[3].ToString());
 | 
						|
                int TotalPages = int.Parse(values[4].ToString());
 | 
						|
 | 
						|
                return ((CurrentPage - 1) * PageSize + 1) + "-" + (CurrentPage * PageSize > TotalPages ? TotalPages : CurrentPage * PageSize) + "/" + TotalPages; ;
 | 
						|
            }
 | 
						|
            return false;
 | 
						|
        }
 | 
						|
 | 
						|
        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
 | 
						|
        {
 | 
						|
            throw new NotImplementedException();
 | 
						|
        }
 | 
						|
    }
 | 
						|
}
 |