Iyon_Groznyy

Untitled

Sep 10th, 2020
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.05 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections.ObjectModel;
  4. using System.ComponentModel;
  5. using System.Globalization;
  6. using System.Net.Http.Headers;
  7. using System.Windows.Input;
  8. using Xamarin.Forms;
  9. using XamarinTest.Models;
  10.  
  11. namespace XamarinTest.ViewModel
  12. {
  13.     class ReportVM : INotifyPropertyChanged
  14.     {
  15.         public event PropertyChangedEventHandler PropertyChanged;
  16.         ProjectModel projectModel;
  17.         List<Tuple<int, string, string, string, string, bool, string>> report;
  18.         internal int CurrentRow = -1;
  19.         public List<Tuple<int, string, string, string, string, bool, string>> Report
  20.         {
  21.             get => report;
  22.             private set
  23.             {
  24.                 report = value;
  25.                 OnPropertyChanged("Report");
  26.             }
  27.         }
  28.         public ICommand verificateRow { private set; get; }
  29.         public ReportVM()
  30.         {
  31.             projectModel = new ProjectModel();
  32.             Report = new List<Tuple<int, string, string, string, string, bool, string>>()
  33.             {
  34.                 new Tuple<int, string, string, string, string, bool, string> (1, "324", "123", "1", "111",true,"-"),
  35.                 new Tuple<int,string, string, string, string, bool, string> (2, "324", "123", "1", "111",false,"-"),
  36.                 new Tuple<int,string, string, string, string, bool, string> (3, "324", "123", "1", "111",false,"-")
  37.             };
  38.  
  39.             MessagingCenter.Subscribe(this, "Data", (SummaryVM sender, Tuple<ProjectModel, string> pSummaryData) =>
  40.             {
  41.                 pSummaryData.Item1.calculateCoverage();
  42.                 projectModel = pSummaryData.Item1;
  43.                 Report = projectModel.getDataForGrid(pSummaryData.Item2);
  44.             });
  45.  
  46.             verificateRow = new Command(
  47.                 execute: (object o) =>
  48.                 {
  49.                     var array = o.ToString().Trim(new char[] { ' ', '(', ')' }).Split(new char[] { ',' });
  50.                     if(array[5].Trim().Equals("True"))
  51.                     {
  52.                         CurrentRow = int.Parse(array[0].Trim());
  53.                     }
  54.                 },
  55.                 canExecute: (object o) =>
  56.                 {
  57.                     return true;
  58.                 });
  59.         }
  60.  
  61.         internal void verificateStatusChange(string pStatus)
  62.         {
  63.             var tempReport = Report;
  64.             tempReport[CurrentRow - 1] = new Tuple<int, string, string, string, string, bool, string>
  65.             (
  66.                 Report[CurrentRow - 1].Item1,
  67.                 Report[CurrentRow - 1].Item2,
  68.                 Report[CurrentRow - 1].Item3,
  69.                 Report[CurrentRow - 1].Item4,
  70.                 "asdasd",
  71.                 Report[CurrentRow - 1].Item6,
  72.                 pStatus
  73.             );
  74.             Report = tempReport;
  75.             OnPropertyChanged("Report");
  76.         }
  77.  
  78.         protected void OnPropertyChanged(string propName)
  79.         {
  80.             PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propName));
  81.         }
  82.     }
  83. }
  84.  
Add Comment
Please, Sign In to add comment