using System;

using System.Collections.Generic;

using ATK;                              // the RFID SDK reference for the Bluetooth references

using System.Collections.ObjectModel;

using System.ComponentModel;

using Windows.UI.Xaml.Media.Imaging;



namespace Zebra_RFID_Mobile

{

    public class ReaderConfig // global structure which reflects reader's configuration and application flags

    {

        public static bool isConnectComplete = false;

        public static bool isBatteryTimerStopped = false;

        public static connectionClass connectionConfig = new connectionClass();

        public static bool isConnectWithPasswordEnabled = false;

        public static string connectionPassword = "";

        public static SettingsStausClass SettingsStaus = new SettingsStausClass();

        public static string lastRegion = "";  // points to the last region in the list of all supported regions

        public static bool isGetAllRegionsInfoComplete = false; // checks if the get region for all the regions is completed

        public static bool isReaderConnected=false;

        public static bool isBatchModeEventRecieved = false;

        public static bool isInitialSettingsRecieved = false;

        public static bool isGetTagsData = false;

        public static bool isRegionSet = false;

        public static bool isRegionGetComplete = false;

        public static bool isAntennaSetComplete = false;

        public static bool isSingulationSetComplete = false;

        public static bool isStartStopSetComplete = false;

        public static bool isCommandComplete = false;

        public static bool isDPOSetComplete = false;

        public static bool isTagReportSetComplete = false;

        public static bool isPreFilterSetComplete = false;

        public static bool moveToRegioScreen = false;

        public static int batchmode = -1; // gives the batchmode level set

        public static BatchMode BatchMode = new BatchMode(); // tells if opertion is in batch mode

        public static getVersionClass versionInfo = new getVersionClass();

        public static SelectedTagClass selectedTagEPC = new SelectedTagClass();

        public static Command_SetAntennaConfiguration antennaConfigParams = new Command_SetAntennaConfiguration();

        public static int bankSelectedAtInventory=0; // 0 for inventory 1-4 for read       

        public static Response_Status lastMetadataResponse = new Response_Status();

        public static Command_SetQueryParams queryParams = new Command_SetQueryParams();

        public static Command_SetStartTrigger startTriggerParams= new Command_SetStartTrigger();

        public static Command_SetStopTrigger stopTriggerParams= new Command_SetStopTrigger();       

        public static Command_SetReportConfig reportConfigParams = new Command_SetReportConfig();

        public static Command_SetRegulatory regultoryConfigObj = new Command_SetRegulatory();

        public static Command_SetAccessCriteria accessCriteriaParams = new Command_SetAccessCriteria();

        public static Command_SetSelectRecords selectFilterParams = new Command_SetSelectRecords();

        public static Boolean isInventoryRunning=false; // is inventory running from inventory screen

        public static InventoryReadRateClass inventoryReadRate = new InventoryReadRateClass();

        public static StartStopInventory StartStopButtonStatus = new StartStopInventory();

        public static Boolean isInventoryReadRunning = false; // is read running from inventory screen

        public static Boolean isLocateRunning = false;

        public static TimeSpan ReadTimeToAdd = new TimeSpan(0, 0, 1);

        public static bool onTagLocateScreen = false;

        public static Boolean isConfigSaved = false;

        public static Boolean isGetAllRegionsComplete = false; // checks if get supported regions is complete

        public static Boolean isAbortComplete = false;

        public static Boolean isAccessComplete = false;

        public static BatteryLevelClass batteryLevel = new BatteryLevelClass();

        public static Boolean isInventoryScreenTagData; // this parameter is used to differentiate Tag data on basis of screen

                                                 //( i.e. if inventory/read sent form inventory/RapidRead screen or from read screen)

                                                 // also, if no radio operation is ongoing , it is false

        public static bool onInventoryScreen = false; 

        public static bool onRapidReadScreen = false;

        public static bool onAccessScreen = false;

        public static bool isAccessCriteriaSet = false;

        public static bool isSelectRecordSet = false;

        public static AccessDataClass accessTagData = new AccessDataClass();       

        public static LocateDataClass locateData = new LocateDataClass();

        public static DPOImageClass DPOImage = new DPOImageClass();

        public static ObservableCollection<inventoryData> inventoryData = new ObservableCollection<inventoryData>();

        public static ObservableCollection<inventoryData> inventoryRawData = new ObservableCollection<inventoryData>();

        public static ReadTagsinfo TagsRead = new ReadTagsinfo();        

        public static bool isDynmaicPowerEnabled = false;

        public static bool isBeeperOn = false;

        public static ENUM_BEEPER_VOLUME beeperLevel;

        public static int connectedReaderIndex = -1;

        public static List<Regions> regionList = new List<Regions>();

        public static List<string> linkProfiles = new List<string>();

        public static List<LinkProfile> linkProfilesWithIndex = new List<LinkProfile>();

        public static ObservableCollection<Channels> frequencyChannelsSelected = new ObservableCollection<Channels>();

        public static ObservableCollection<Channels> frequencyChannelsAll = new ObservableCollection<Channels>();

        public static List<Regions_Channels> regionsChannelsAll = new List<Regions_Channels>();

        public static String DeviceModel;

        public static String DeviceSerial;

        internal static BatteryDPOImageProp batteryDPO = new BatteryDPOImageProp();

        //public static List<PairedDeviceInfo> _pairedDevices;

        public static bool reportUniqueTags = false;

    }



    internal class BatteryDPOImageProp : INotifyPropertyChanged

    {

        private BitmapImage _Image = new BitmapImage();

        public BitmapImage BatteryDPOImage

        {

            get { return _Image; }

            set

            {

                _Image = value;

                onPropertyChanged(this, "BatteryDPOImage");

            }

        }

        public event PropertyChangedEventHandler PropertyChanged;



        private void onPropertyChanged(object sender, string propertyName)

        {

            if (this.PropertyChanged != null)

            {

                PropertyChanged(sender, new PropertyChangedEventArgs(propertyName));

            }

        }

    }



    public class SettingsStausClass : INotifyPropertyChanged

    {

        private string _SettingsStatus;

        public string ResponseStatusMsg;

        public string SettingsStatus

        {

            get { return _SettingsStatus; }

            set

            {

                _SettingsStatus = value;

                onPropertyChanged(this, "SettingsStatus");



            }

        }

        private bool _SettingsStatusShow;

        public bool SettingsStatusShow

        {

            get { return _SettingsStatusShow; }

            set

            {

                _SettingsStatusShow = value;

                onPropertyChanged(this, "SettingsStatusShow");

            }

        }



        public event PropertyChangedEventHandler PropertyChanged;



        private void onPropertyChanged(object sender, string propertyName)

        {

            if (this.PropertyChanged != null)

            {

                PropertyChanged(sender, new PropertyChangedEventArgs(propertyName));

            }

        }

    }



    public class connectionClass : INotifyPropertyChanged

    {

        Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;

        private bool _autoReconnect;

        public bool autoReconnect

        {

            get { return _autoReconnect; }

            set

            {

                _autoReconnect = value;

                onPropertyChanged(this, "autoReconnect");

                localSettings.Values["autoReconnect"] = value;

            }

        }



        private bool _readerAvailable;

        public bool readerAvailable

        {

            get { return _readerAvailable; }

            set

            {

                _readerAvailable = value;

                onPropertyChanged(this, "readerAvailable");

                localSettings.Values["readerAvailable"] = value;

            }

        }

        private bool _readerConnection;

        public bool readerConnection

        {

            get { return _readerConnection; }

            set

            {

                _readerConnection = value;

                onPropertyChanged(this, "readerConnection");

                localSettings.Values["readerConnection"] = value;

            }

        }

        private bool _readerBatteryStatus;

        public bool readerBatteryStatus

        {

            get { return _readerBatteryStatus; }

            set

            {

                _readerBatteryStatus = value;

                onPropertyChanged(this, "readerBatteryStatus");

                localSettings.Values["readerBatteryStatus"] = value;

            }

        }

        private bool _exportData;

        public bool exportData

        {

            get { return _exportData; }

            set

            {

                _exportData = value;

                onPropertyChanged(this, "exportData");

                localSettings.Values["exportData"] = value;

            }

        }

        

        public event PropertyChangedEventHandler PropertyChanged;



        private void onPropertyChanged(object sender, string propertyName)

        {

            if (this.PropertyChanged != null)

            {

                PropertyChanged(sender, new PropertyChangedEventArgs(propertyName));

            }

        }

    }



    public class getVersionClass : INotifyPropertyChanged

    {       

        private string _Module;

        public string Module

        {

            get { return _Module; }

            set

            {

                _Module = value;

                onPropertyChanged(this, "Module");



            }

        }

        private string _Radio;

        public string Radio

        {

            get { return _Radio; }

            set

            {

                _Radio = value;

                onPropertyChanged(this, "Radio");



            }

        }

        public event PropertyChangedEventHandler PropertyChanged;



        private void onPropertyChanged(object sender, string propertyName)

        {

            if (this.PropertyChanged != null)

            {

                PropertyChanged(sender, new PropertyChangedEventArgs(propertyName));

            }

        }

    }



    public class AccessDataClass : INotifyPropertyChanged

    {

        private string _RecievedData;

        public string RecievedData

        {

            get { return _RecievedData; }

            set

            {

                _RecievedData = value;

                onPropertyChanged(this, "RecievedData");



            }

        }



        private string _AccessStatus;

        public string RecievedStatus

        {

            get { return _AccessStatus; }

            set

            {

                _AccessStatus = value;

                onPropertyChanged(this, "RecievedStatus");

            }

        }



        private bool _AccessStatusShow;

        public bool AccessStatusShow

        {

            get { return _AccessStatusShow; }

            set

            {

                _AccessStatusShow = value;

                onPropertyChanged(this, "AccessStatusShow");

            }

        }



        public event PropertyChangedEventHandler PropertyChanged;



        private void onPropertyChanged(object sender, string propertyName)

        {

            if (this.PropertyChanged != null)

            {

                PropertyChanged(sender, new PropertyChangedEventArgs(propertyName));

            }

        }

    }



    public class LocateDataClass : INotifyPropertyChanged

    {

        private string _LocateData;

        public string LocateData

        {

            get { return _LocateData; }

            set

            {

                _LocateData = value;

                onPropertyChanged(this, "LocateData");



            }

        }



        private string _SelectedTag;

        public string SelectedTag

        {

            get { return _SelectedTag; }

            set

            {

                _SelectedTag = value;

                onPropertyChanged(this, "SelectedTag");



            }

        }



        private string _LocateStartStop;

        public string LocateStartStop

        {

            get { return _LocateStartStop; }

            set

            {

                _LocateStartStop = value;

                onPropertyChanged(this, "LocateStartStop");



            }

        }

        private bool _LocateTagID_ON;

        public bool LocateTagID_ON

        {

            get { return _LocateTagID_ON; }

            set

            {

                _LocateTagID_ON = value;

                onPropertyChanged(this, "LocateTagID_ON");



            }

        }



        public event PropertyChangedEventHandler PropertyChanged;



        private void onPropertyChanged(object sender, string propertyName)

        {

            if (this.PropertyChanged != null)

            {

                PropertyChanged(sender, new PropertyChangedEventArgs(propertyName));

            }

        }

    }



    public class SelectedTagClass : INotifyPropertyChanged

    {

        private string _SelectedTag;

        public string SelectedTag

        {

            get { return _SelectedTag; }

            set

            {

                _SelectedTag = value;

                onPropertyChanged(this, "SelectedTag");



            }

        }

        public event PropertyChangedEventHandler PropertyChanged;



        private void onPropertyChanged(object sender, string propertyName)

        {

            if (this.PropertyChanged != null)

            {

                PropertyChanged(sender, new PropertyChangedEventArgs(propertyName));

            }

        }

    }



    public class StartStopInventory : INotifyPropertyChanged

    {

        private string _STARTSTATUS;

        public string STARTSTATUS

        {

            get { return _STARTSTATUS; }

            set

            {

                _STARTSTATUS = value;

                onPropertyChanged(this, "STARTSTATUS");

                if (value.Equals("START"))

                    isBankListEnabled = true;

                else

                    isBankListEnabled = false;

            }

        }        

        private bool _isBankListEnabled;

        public bool isBankListEnabled

        {

            get { return _isBankListEnabled; }

            set

            {

                _isBankListEnabled = value;

                onPropertyChanged(this, "isBankListEnabled");



            }

        }

        public event PropertyChangedEventHandler PropertyChanged;



        private void onPropertyChanged(object sender, string propertyName)

        {

            if (this.PropertyChanged != null)

            {

                PropertyChanged(sender, new PropertyChangedEventArgs(propertyName));

            }

        }

    }



    public class DPOImageClass : INotifyPropertyChanged

    {

        private BitmapImage _DPOImage = new BitmapImage();

        public BitmapImage DPOImage

        {

            get { return _DPOImage; }

            set

            {

                _DPOImage = value;

                onPropertyChanged(this, "DPOImage");

            }

        }





        public event PropertyChangedEventHandler PropertyChanged;



        private void onPropertyChanged(object sender, string propertyName)

        {

            if (this.PropertyChanged != null)

            {

                PropertyChanged(sender, new PropertyChangedEventArgs(propertyName));

            }

        }

    }

    

    public class BatteryLevelClass : INotifyPropertyChanged

    {

        private string _BatteryStatus;

        public string BatteryStatus

        {

            get { return _BatteryStatus; }

            set

            {

                _BatteryStatus = value;

                onPropertyChanged(this, "BatteryStatus");



            }

        }  



        private String _BatteryLevel;

        public String BatteryLevel

        {

            get { return _BatteryLevel; }

            set

            {

                _BatteryLevel = value;

                onPropertyChanged(this, "BatteryLevel");

            }

        }



        private BitmapImage _BatteryImage= new BitmapImage();

        public BitmapImage BatteryImage

        {

            get { return _BatteryImage; }

            set

            {

                _BatteryImage = value;

                onPropertyChanged(this, "BatteryImage");

            }

        }

        

        public event PropertyChangedEventHandler PropertyChanged;



        private void onPropertyChanged(object sender, string propertyName)

        {

            if (this.PropertyChanged != null)

            {

                PropertyChanged(sender, new PropertyChangedEventArgs(propertyName));

            }

        }

    }



    public class Channels : INotifyPropertyChanged

    {

        private string _Channel;

        public string Channel

        {

            get { return _Channel; }

            set

            {

                _Channel = value;

                onPropertyChanged(this, "Channel");



            }

        }



        private bool _ChannelEnable;

        public bool ChannelEnable

        {

            get { return _ChannelEnable; }

            set

            {

                _ChannelEnable = value;

                onPropertyChanged(this, "ChannelEnable");



            }

        }



        private bool _ChannelSelected;

        public bool ChannelSelected

        {

            get { return _ChannelSelected; }

            set

            {

                _ChannelSelected = value;

                onPropertyChanged(this, "ChannelSelected");



            }

        }



        public event PropertyChangedEventHandler PropertyChanged;



        private void onPropertyChanged(object sender, string propertyName)

        {

            if (this.PropertyChanged != null)

            {

                PropertyChanged(sender, new PropertyChangedEventArgs(propertyName));

            }

        }

    }



    public class Regions_Channels

    {

        private string _RegionCode;

        public string RegionCode

        {

            get { return _RegionCode;}

            set{ _RegionCode= value;}

        }



        private string _ChannelList;

        public string ChannelList

        {

            get { return _ChannelList; }

            set { _ChannelList = value; }

        }

        private bool _isHoppingCofigurable;

        public bool isHoppingCofigurable

        {

            get { return _isHoppingCofigurable; }

            set { _isHoppingCofigurable = value; }

        }

    }



    public class Regions

    {

        private string _Region;

        public string Region

        {

            get { return _Region; }

            set {_Region = value; }

        }

        private string _RegionCode;

        public string RegionCode

        {

            get { return _RegionCode; }

            set { _RegionCode = value;}

        }

    }



    public class LinkProfile

    {

        private byte _RFindex;

        public byte RFindex

        {

            get { return _RFindex; }

            set { _RFindex = value;}

        }



        private string _LProfile;

        public string LProfile

        {

            get { return _LProfile; }

            set {_LProfile = value; }

        }

    }



    public class InventoryReadRateClass : INotifyPropertyChanged

    {

        private TimeSpan _ReadTime;

        public TimeSpan ReadTime

        {

            get { return _ReadTime; }

            set

            {

                _ReadTime = value;

                onPropertyChanged(this, "ReadTime");

            }

        }



        private int _ReadRate;

        public int ReadRate

        {

            get { return _ReadRate; }

            set

            {

                _ReadRate = value;

                onPropertyChanged(this, "ReadRate");

            }

        }

        public event PropertyChangedEventHandler PropertyChanged;



        private void onPropertyChanged(object sender, string propertyName)

        {

            if (this.PropertyChanged != null)

            {

                PropertyChanged(sender, new PropertyChangedEventArgs(propertyName));

            }

        }

    }



    public class inventoryData : INotifyPropertyChanged

    {

        private string _EPCID;

        public string EPCID

        {

            get { return _EPCID; }

            set

            {

                _EPCID = value;

                onPropertyChanged(this, "EPCID");

            }

        }



        private int _Count;

        public int Count

        {

            get { return _Count; }

            set

            {

                _Count = value;

                onPropertyChanged(this, "Count");

            }

        }

        

        private string _Visible;

        public string Visible

        {

            get { return _Visible; }

            set

            {

                _Visible = value;

                onPropertyChanged(this, "Visible");

            }

        }



        private string _PC;

        public string PC

        {

            get { return _PC; }

            set

            {

                _PC = value;

                onPropertyChanged(this, "PC");

            }

        }

        private string _PCVisible;

        public string PCVisible

        {

            get { return _PCVisible; }

            set

            {

                _PCVisible = value;

                onPropertyChanged(this, "PCVisible");

            }

        }

        private string _RSSI;

        public string RSSI

        {

            get { return _RSSI; }

            set

            {

                _RSSI = value;

                onPropertyChanged(this, "RSSI");

            }

        }



        private string _RSSIVisible;

        public string RSSIVisible

        {

            get { return _RSSIVisible; }

            set

            {

                _RSSIVisible = value;

                onPropertyChanged(this, "RSSIVisible");

            }

        }



        private string _Phase;

        public string Phase

        {

            get { return _Phase; }

            set

            {

                _Phase = value;

                onPropertyChanged(this, "Phase");

            }

        }



        private string _PhaseVisible;

        public string PhaseVisible

        {

            get { return _PhaseVisible; }

            set

            {

                _PhaseVisible = value;

                onPropertyChanged(this, "PhaseVisible");

            }

        }

        

        private string _Channel;

        public string Channel

        {

            get { return _Channel; }

            set

            {

                _Channel = value;

                onPropertyChanged(this, "Channel");

            }

        }

        private string _ChannelVisible;

        public string ChannelVisible

        {

            get { return _ChannelVisible; }

            set

            {

                _ChannelVisible = value;

                onPropertyChanged(this, "ChannelVisible");

            }

        }



        private string _AccessData;

        public string AccessData

        {

            get { return _AccessData; }

            set

            {

                _AccessData = value;

                onPropertyChanged(this, "AccessData");

            }

        }



        private string _AccessDataLabel;

        public string AccessDataLabel

        {

            get { return _AccessDataLabel; }

            set

            {

                _AccessDataLabel = value;

                onPropertyChanged(this, "AccessDataLabel");

            }

        }



        private string _AccessDataVisible;



        public string AccessDataVisible

        {

            get { return _AccessDataVisible; }

            set

            {

                _AccessDataVisible = value;

                onPropertyChanged(this, "AccessDatalVisible");

            }

        }



        public event PropertyChangedEventHandler PropertyChanged;



        private void onPropertyChanged(object sender, string propertyName)

        {

            if (this.PropertyChanged != null)

            {

                PropertyChanged(sender, new PropertyChangedEventArgs(propertyName));

            }

        }

    }



    public class ReadTagsinfo : INotifyPropertyChanged

    {

        private int _ReadTags;

        public int ReadTags

        {

            get { return _ReadTags; }

            set

            {

                _ReadTags = value;

                onPropertyChanged(this, "ReadTags");

            }

        }



        private int _UniqueCount;

        private string _UniqueCountVisible;



        public int UniqueCount

        {

            get { return _UniqueCount; }

            set

            {

                _UniqueCount = value;

                onPropertyChanged(this, "UniqueCount");

            }

        }



        public string UniqueCountVisible

        {

            get { return _UniqueCountVisible; }

            set

            {

                _UniqueCountVisible = value;

                onPropertyChanged(this, "UniqueCountVisible");

            }

        }



        public event PropertyChangedEventHandler PropertyChanged;



        private void onPropertyChanged(object sender, string propertyName)

        {

            if (this.PropertyChanged != null)

            {

                PropertyChanged(sender, new PropertyChangedEventArgs(propertyName));

            }

        }

    }



    public class BatchMode : INotifyPropertyChanged

    {

        private bool _BatchModeEnabled;

        private string _BatchModeEnableVisible;



        public bool isEnabled

        {

            get { return _BatchModeEnabled; }

            set

            {

                _BatchModeEnabled = value;

                BatchModeEnable = _BatchModeEnabled ? "Visible" : "Collapsed";

                ReaderConfig.TagsRead.UniqueCountVisible = _BatchModeEnabled ? "Collapsed" : "Visible";

            }

        }



        public string BatchModeEnable

        {

            get { return _BatchModeEnableVisible; }

            set

            {

                _BatchModeEnableVisible = value;

                onPropertyChanged(this, "BatchModeEnable");

            }

        }



        public event PropertyChangedEventHandler PropertyChanged;



        private void onPropertyChanged(object sender, string propertyName)

        {

            if (this.PropertyChanged != null)

            {

                PropertyChanged(sender, new PropertyChangedEventArgs(propertyName));

            }

        }

    }   

}

