| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- using System;
- using System.Collections.Generic;
- using System.Globalization;
- using System.Linq;
- using InABox.Mobile;
- using Xamarin.Forms;
- namespace PRS.Mobile
- {
- public class TransactionColorConverter : BindableObject, IMultiValueConverter
- {
- public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
- {
- var result = Color.Transparent;
- if (values?.Length == 2 && values.First() is StockTransaction transaction && values.Last() is Guid guid)
- {
- result = guid == (transaction?.Source?.LocationID ?? Guid.Empty)
- ? Color.Orange
- : Color.LightGreen;
- }
- return result;
- }
- public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- }
- public class TransactionDisplayConverter : BindableObject, IMultiValueConverter
- {
- public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
- {
- if (values?.Length == 2 && values.First() is StockTransaction transaction && values.Last() is Guid guid)
- {
- StockTransactionView view = guid == (transaction?.Source?.LocationID ?? Guid.Empty)
- ? StockTransactionView.Source
- : StockTransactionView.Target;
- return transaction?.Display(view) ?? string.Empty;
- }
- return "";
- }
- public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- }
-
- // public class StockTransactionConverter : AbstractConverter<StockTransaction, string>
- // {
- //
- // public StockTransactionView View { get; set; }
- //
- // public StockTransactionProperty Property { get; set; }
- //
- // protected override string? Convert(StockTransaction? value, object? parameter = null)
- // {
- // if (value == null)
- // return "";
- //
- // switch (Property)
- // {
- // case StockTransactionProperty.Style when value.Source.StyleID != value.Target.StyleID:
- // return View == StockTransactionView.Source
- // ? value.Source.StyleCode
- // : value.Target.StyleCode;
- // case StockTransactionProperty.Location when value.Source.LocationID != value.Target.LocationID:
- // return View == StockTransactionView.Source
- // ? value.Source.LocationCode
- // : value.Target.LocationCode;
- // case StockTransactionProperty.Job when value.Source.JobID != value.Target.JobID:
- // return View == StockTransactionView.Source
- // ? $"Job {value.Source.JobNumber}"
- // : $"Job {value.Target.JobNumber}";
- // default:
- // return "";
- // }
- //
- // }
- // }
- }
|